Class: ZaiPayment::Resources::PayId
- Inherits:
-
Object
- Object
- ZaiPayment::Resources::PayId
- Defined in:
- lib/zai_payment/resources/pay_id.rb
Overview
PayID resource for managing Zai PayID registrations
Constant Summary collapse
- CREATE_FIELD_MAPPING =
Map of attribute keys to API field names for create
{ pay_id: :pay_id, type: :type, details: :details }.freeze
- VALID_TYPES =
Valid PayID types
%w[EMAIL].freeze
- VALID_STATUSES =
Valid PayID statuses for update
%w[deregistered].freeze
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
-
#create(virtual_account_id, **attributes) ⇒ Response
Register a PayID for a given Virtual Account.
-
#initialize(client: nil) ⇒ PayId
constructor
A new instance of PayId.
-
#show(pay_id_id) ⇒ Response
Show a specific PayID.
-
#update_status(pay_id_id, status) ⇒ Response
Update Status for a PayID.
Constructor Details
#initialize(client: nil) ⇒ PayId
Returns a new instance of PayId.
24 25 26 |
# File 'lib/zai_payment/resources/pay_id.rb', line 24 def initialize(client: nil) @client = client || Client.new(base_endpoint: :va_base) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/zai_payment/resources/pay_id.rb', line 9 def client @client end |
Instance Method Details
#create(virtual_account_id, **attributes) ⇒ Response
Register a PayID for a given Virtual Account
53 54 55 56 57 58 59 |
# File 'lib/zai_payment/resources/pay_id.rb', line 53 def create(virtual_account_id, **attributes) validate_id!(virtual_account_id, 'virtual_account_id') validate_create_attributes!(attributes) body = build_create_body(attributes) client.post("/virtual_accounts/#{virtual_account_id}/pay_ids", body: body) end |
#show(pay_id_id) ⇒ Response
Show a specific PayID
72 73 74 75 |
# File 'lib/zai_payment/resources/pay_id.rb', line 72 def show(pay_id_id) validate_id!(pay_id_id, 'pay_id_id') client.get("/pay_ids/#{pay_id_id}") end |
#update_status(pay_id_id, status) ⇒ Response
Update Status for a PayID
Update the status of a PayID. Currently, this endpoint only supports deregistering PayIDs by setting the status to 'deregistered'. This is an asynchronous operation that returns a 202 Accepted response.
96 97 98 99 100 101 102 |
# File 'lib/zai_payment/resources/pay_id.rb', line 96 def update_status(pay_id_id, status) validate_id!(pay_id_id, 'pay_id_id') validate_status!(status) body = { status: status } client.patch("/pay_ids/#{pay_id_id}/status", body: body) end |