mirror of
https://github.com/internetee/registry.git
synced 2025-07-29 22:16:19 +02:00
Added ApiUser and WhiteIp endpoints to REPP API
This commit is contained in:
parent
0442f7f087
commit
b84e9e1579
9 changed files with 206 additions and 3 deletions
38
lib/serializers/repp/api_user.rb
Normal file
38
lib/serializers/repp/api_user.rb
Normal file
|
@ -0,0 +1,38 @@
|
|||
module Serializers
|
||||
module Repp
|
||||
class ApiUser
|
||||
attr_reader :user
|
||||
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
|
||||
def to_json(obj = user)
|
||||
json = {
|
||||
id: obj.id,
|
||||
name: obj.username,
|
||||
password: obj.plain_text_password,
|
||||
identity_code: obj.identity_code,
|
||||
roles: obj.roles.join(', '),
|
||||
active: obj.active,
|
||||
accredited: obj.accredited?,
|
||||
accreditation_expired: obj.accreditation_expired?,
|
||||
accreditation_expire_date: obj.accreditation_expire_date,
|
||||
created_at: obj.created_at,
|
||||
updated_at: obj.updated_at,
|
||||
}
|
||||
json[:certificates] = certificates
|
||||
json
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def certificates
|
||||
user.certificates.map do |x|
|
||||
subject = x.csr ? x.parsed_csr.try(:subject) : x.parsed_crt.try(:subject)
|
||||
{ subject: subject.to_s, status: x.status }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -81,6 +81,7 @@ module Serializers
|
|||
total: invoice.total,
|
||||
recipient: invoice.buyer.billing_email,
|
||||
monthly_invoice: invoice.monthly_invoice,
|
||||
reference_no: invoice.reference_no
|
||||
}
|
||||
end
|
||||
# rubocop:enable Metrics/MethodLength
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue