class SynapsePayments::Client
Constants
- API_LIVE
- API_TEST
Attributes
api_base[R]
client_id[RW]
client_secret[RW]
sandbox_mode[RW]
subscriptions[R]
timeout_options[RW]
users[R]
Public Class Methods
new(options={}) { |self| ... }
click to toggle source
Initializes a new Client
object
@param options [Hash] @return [SynapsePayments::Client]
# File lib/synapse_payments/client.rb, line 16 def initialize(options={}) @sandbox_mode = true @timeout_options = { write: 2, connect: 5, read: 10 } options.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) @subscriptions = Subscriptions.new(self) end
Public Instance Methods
credentials()
click to toggle source
@return [Hash]
# File lib/synapse_payments/client.rb, line 33 def credentials { client_id: client_id, client_secret: client_secret } end
credentials?()
click to toggle source
@return [Boolean]
# File lib/synapse_payments/client.rb, line 41 def credentials? credentials.values.all? end
delete(path:, oauth_key: nil, fingerprint: nil)
click to toggle source
# File lib/synapse_payments/client.rb, line 64 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)
click to toggle source
# File lib/synapse_payments/client.rb, line 52 def get(path:, oauth_key: nil, fingerprint: nil) Request.new(client: self, method: :get, path: path, oauth_key: oauth_key, fingerprint: fingerprint).perform end
institutions()
click to toggle source
@return [Array]
# File lib/synapse_payments/client.rb, line 46 def institutions institutions = HTTP.get('https://synapsepay.com/api/v3/institutions/show').parse symbolize_keys!(institutions) institutions[:banks] end
patch(path:, json:, oauth_key: nil, fingerprint: nil)
click to toggle source
# File lib/synapse_payments/client.rb, line 60 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, idempotency_key: nil)
click to toggle source
# File lib/synapse_payments/client.rb, line 56 def post(path:, json:, oauth_key: nil, fingerprint: nil, idempotency_key: nil) Request.new(client: self, method: :post, path: path, oauth_key: oauth_key, fingerprint: fingerprint, json: json, idempotency_key: idempotency_key).perform end
symbolize_keys!(object)
click to toggle source
# File lib/synapse_payments/client.rb, line 68 def symbolize_keys!(object) if object.is_a?(Array) object.each_with_index do |val, index| object[index] = symbolize_keys!(val) end elsif object.is_a?(Hash) object.keys.each do |key| object[key.to_sym] = symbolize_keys!(object.delete(key)) end end object end