Class: SynapsePayments::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ SynapsePayments::Client

Initializes a new Client object

Parameters:

  • options (Hash) (defaults to: {})

Yields:

  • (_self)

Yield Parameters:



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/synapse_payments/client.rb', line 16

def initialize(options={})
  @sandbox_mode = true

  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)
end

Instance Attribute Details

#api_baseObject (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_idObject

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_secretObject

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_modeObject

Returns the value of attribute sandbox_mode.



9
10
11
# File 'lib/synapse_payments/client.rb', line 9

def sandbox_mode
  @sandbox_mode
end

#usersObject (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

#credentialsHash

Returns:

  • (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

Returns:

  • (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