mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 05:56:20 +02:00
Added invoice recipient validation
This commit is contained in:
parent
de5872fb40
commit
885206d075
3 changed files with 11 additions and 2 deletions
|
@ -37,8 +37,17 @@ module Repp
|
||||||
|
|
||||||
api :post, '/repp/v1/invoices/:id/send_to_recipient'
|
api :post, '/repp/v1/invoices/:id/send_to_recipient'
|
||||||
desc 'Send invoice pdf to recipient'
|
desc 'Send invoice pdf to recipient'
|
||||||
|
param :invoice, Hash, required: true, desc: 'Invoice data for sending to recipient' do
|
||||||
|
param :id, String, required: true, desc: 'Invoice id'
|
||||||
|
param :recipient, String, required: true, desc: 'Invoice receipient email'
|
||||||
|
end
|
||||||
def send_to_recipient
|
def send_to_recipient
|
||||||
recipient = invoice_params[:recipient]
|
recipient = invoice_params[:recipient]
|
||||||
|
unless recipient.present?
|
||||||
|
handle_non_epp_errors(@invoice, 'Invoice recipient cannot be empty')
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
InvoiceMailer.invoice_email(invoice: @invoice, recipient: recipient)
|
InvoiceMailer.invoice_email(invoice: @invoice, recipient: recipient)
|
||||||
.deliver_now
|
.deliver_now
|
||||||
serializer = Serializers::Repp::Invoice.new(@invoice, simplify: true)
|
serializer = Serializers::Repp::Invoice.new(@invoice, simplify: true)
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Registrar < ApplicationRecord
|
||||||
|
|
||||||
alias_attribute :contact_email, :email
|
alias_attribute :contact_email, :email
|
||||||
|
|
||||||
WHOIS_TRIGGERS = %w(name email phone street city state zip)
|
WHOIS_TRIGGERS = %w[name email phone street city state zip].freeze
|
||||||
|
|
||||||
after_commit :update_whois_records
|
after_commit :update_whois_records
|
||||||
def update_whois_records
|
def update_whois_records
|
||||||
|
|
|
@ -13,7 +13,7 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
def self.from_omniauth(omniauth_hash)
|
def self.from_omniauth(omniauth_hash)
|
||||||
uid = omniauth_hash['uid']
|
uid = omniauth_hash['uid']
|
||||||
identity_code = uid.slice(2..-1)
|
identity_code = uid&.slice(2..-1)
|
||||||
# country_code = uid.slice(0..1)
|
# country_code = uid.slice(0..1)
|
||||||
|
|
||||||
find_by(identity_code: identity_code, active: true)
|
find_by(identity_code: identity_code, active: true)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue