Module: Jamm::Customer
- Defined in:
- lib/jamm/customer.rb
Constant Summary collapse
- KycStatus =
Embed enum statuses into Customer module for easier access and not to leak OpenAPI namespace into merchant codebase.
-
Before: Jamm::OpenAPI::KycStatus
-
After: Jamm::Customer::KycStatus
-
Jamm::OpenAPI::KycStatus
- PaymentAuthorizationStatus =
Jamm::OpenAPI::PaymentAuthorizationStatus
Class Method Summary collapse
- .create(buyer:, merchant: nil) ⇒ Object
- .delete(id, merchant: nil) ⇒ Object
- .get(id_or_email, merchant: nil) ⇒ Object
- .get_contract(id, merchant: nil) ⇒ Object
- .update(id, params, merchant: nil) ⇒ Object
Class Method Details
.create(buyer:, merchant: nil) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jamm/customer.rb', line 19 def self.create(buyer:, merchant: nil) handler = Jamm::Client.handler(merchant: merchant) r = Jamm::OpenAPI::CustomerApi.new(handler).create( buyer: buyer ) r.customer rescue Jamm::OpenAPI::ApiError => e raise Jamm::ApiError.from_error(e) end |
.delete(id, merchant: nil) ⇒ Object
65 66 67 68 69 70 |
# File 'lib/jamm/customer.rb', line 65 def self.delete(id, merchant: nil) handler = Jamm::Client.handler(merchant: merchant) Jamm::OpenAPI::CustomerApi.new(handler).delete(id) rescue Jamm::OpenAPI::ApiError => e raise Jamm::ApiError.from_error(e) end |
.get(id_or_email, merchant: nil) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jamm/customer.rb', line 31 def self.get(id_or_email, merchant: nil) handler = Jamm::Client.handler(merchant: merchant) r = Jamm::OpenAPI::CustomerApi.new(handler).get(id_or_email) if r.customer.activated.nil? # Activated flag requires explicit binding on false, since RPC/OpenAPI does # not return false value. r.customer.activated = false end r.customer rescue Jamm::OpenAPI::ApiError => e raise Jamm::ApiError.from_error(e) end |
.get_contract(id, merchant: nil) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/jamm/customer.rb', line 47 def self.get_contract(id, merchant: nil) handler = Jamm::Client.handler(merchant: merchant) Jamm::OpenAPI::CustomerApi.new(handler).get_contract(id) rescue Jamm::OpenAPI::ApiError => e return nil if [404].include?(e.code) raise Jamm::ApiError.from_error(e) end |
.update(id, params, merchant: nil) ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/jamm/customer.rb', line 56 def self.update(id, params, merchant: nil) handler = Jamm::Client.handler(merchant: merchant) r = Jamm::OpenAPI::CustomerApi.new(handler).update(id, params) r.customer rescue Jamm::OpenAPI::ApiError => e raise Jamm::ApiError.from_error(e) end |