Class: Squake::Purchase
- Inherits:
-
Object
- Object
- Squake::Purchase
- Extended by:
- T::Sig
- Defined in:
- lib/squake/purchase.rb
Constant Summary collapse
- ENDPOINT =
T.let('/v2/purchases', String)
Class Method Summary collapse
- .cancel(client:, id:) ⇒ Object
- .create(client:, pricing:, confirmation_document: nil, certificate_document: nil, metadata: nil, external_reference: SecureRandom.uuid, expand: []) ⇒ Object
- .retrieve(client:, id:) ⇒ Object
Class Method Details
.cancel(client:, id:) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/squake/purchase.rb', line 68 def self.cancel(client:, id:) result = client.call( path: "#{ENDPOINT}/#{id}/cancel", method: :post, ) raise Squake::APIError.new(response: result) unless result.success? Squake::Model::Purchase.from_api_response( T.cast(result.body, T::Hash[Symbol, T.untyped]), ) end |
.create(client:, pricing:, confirmation_document: nil, certificate_document: nil, metadata: nil, external_reference: SecureRandom.uuid, expand: []) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/squake/purchase.rb', line 23 def self.create(client:, pricing:, confirmation_document: nil, certificate_document: nil, metadata: nil, external_reference: SecureRandom.uuid, expand: []) result = client.call( path: ENDPOINT, method: :post, params: { pricing: pricing, confirmation_document: confirmation_document, certificate_document: certificate_document, metadata: , external_reference: external_reference, expand: , }, ) raise Squake::APIError.new(response: result) unless result.success? Squake::Model::Purchase.from_api_response( T.cast(result.body, T::Hash[Symbol, T.untyped]), ) end |
.retrieve(client:, id:) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/squake/purchase.rb', line 50 def self.retrieve(client:, id:) result = client.call( path: "#{ENDPOINT}/#{id}", ) return nil if result.code == 404 raise Squake::APIError.new(response: result) unless result.success? Squake::Model::Purchase.from_api_response( T.cast(result.body, T::Hash[Symbol, T.untyped]), ) end |