Class: SynapsePayments::Client
- Inherits:
-
Object
- Object
- SynapsePayments::Client
- Defined in:
- lib/synapse_payments/client.rb
Constant Summary collapse
- API_TEST =
'https://sandbox.synapsepay.com/api/3'- API_LIVE =
'https://synapsepay.com/api/3'
Instance Attribute Summary collapse
-
#api_base ⇒ Object
readonly
Returns the value of attribute api_base.
-
#client_id ⇒ Object
Returns the value of attribute client_id.
-
#client_secret ⇒ Object
Returns the value of attribute client_secret.
-
#sandbox_mode ⇒ Object
Returns the value of attribute sandbox_mode.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Instance Method Summary collapse
- #credentials ⇒ Hash
- #credentials? ⇒ Boolean
- #delete(path:, oauth_key: nil, fingerprint: nil) ⇒ Object
- #get(path:, oauth_key: nil, fingerprint: nil) ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ SynapsePayments::Client
constructor
Initializes a new Client object.
- #patch(path:, json:, oauth_key: nil, fingerprint: nil) ⇒ Object
- #post(path:, json:, oauth_key: nil, fingerprint: nil) ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ SynapsePayments::Client
Initializes a new Client object
16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/synapse_payments/client.rb', line 16 def initialize(={}) @sandbox_mode = true .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? @api_base = @sandbox_mode ? API_TEST : API_LIVE @users = Users.new(self) end |
Instance Attribute Details
#api_base ⇒ Object (readonly)
Returns the value of attribute api_base.
10 11 12 |
# File 'lib/synapse_payments/client.rb', line 10 def api_base @api_base end |
#client_id ⇒ Object
Returns the value of attribute client_id.
9 10 11 |
# File 'lib/synapse_payments/client.rb', line 9 def client_id @client_id end |
#client_secret ⇒ Object
Returns the value of attribute client_secret.
9 10 11 |
# File 'lib/synapse_payments/client.rb', line 9 def client_secret @client_secret end |
#sandbox_mode ⇒ Object
Returns the value of attribute sandbox_mode.
9 10 11 |
# File 'lib/synapse_payments/client.rb', line 9 def sandbox_mode @sandbox_mode end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
10 11 12 |
# File 'lib/synapse_payments/client.rb', line 10 def users @users end |
Instance Method Details
#credentials ⇒ Hash
31 32 33 34 35 36 |
# File 'lib/synapse_payments/client.rb', line 31 def credentials { client_id: client_id, client_secret: client_secret } end |
#credentials? ⇒ Boolean
39 40 41 |
# File 'lib/synapse_payments/client.rb', line 39 def credentials? credentials.values.all? end |
#delete(path:, oauth_key: nil, fingerprint: nil) ⇒ Object
55 56 57 |
# File 'lib/synapse_payments/client.rb', line 55 def delete(path:, oauth_key: nil, fingerprint: nil) Request.new(client: self, method: :delete, path: path, oauth_key: oauth_key, fingerprint: fingerprint).perform end |
#get(path:, oauth_key: nil, fingerprint: nil) ⇒ Object
43 44 45 |
# File 'lib/synapse_payments/client.rb', line 43 def get(path:, oauth_key: nil, fingerprint: nil) Request.new(client: self, method: :get, path: path, oauth_key: oauth_key, fingerprint: fingerprint).perform end |
#patch(path:, json:, oauth_key: nil, fingerprint: nil) ⇒ Object
51 52 53 |
# File 'lib/synapse_payments/client.rb', line 51 def patch(path:, json:, oauth_key: nil, fingerprint: nil) Request.new(client: self, method: :patch, path: path, oauth_key: oauth_key, fingerprint: fingerprint, json: json).perform end |
#post(path:, json:, oauth_key: nil, fingerprint: nil) ⇒ Object
47 48 49 |
# File 'lib/synapse_payments/client.rb', line 47 def post(path:, json:, oauth_key: nil, fingerprint: nil) Request.new(client: self, method: :post, path: path, oauth_key: oauth_key, fingerprint: fingerprint, json: json).perform end |