Class: SynapsePayRest::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse_pay_rest/client.rb

Overview

Initializes various wrapper settings such as development mode and request header values. Also stores and initializes endpoint class instances (Users, Nodes, Transactions) for making API calls.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, client_secret:, ip_address:, fingerprint: nil, development_mode: true, **options) ⇒ Client

Returns a new instance of Client.

Parameters:

  • client_id (String)

    should be stored in environment variable

  • client_secret (String)

    should be stored in environment variable

  • ip_address (String)

    user’s IP address

  • fingerprint (String) (defaults to: nil)

    a hashed value, either unique to user or static

  • development_mode (String) (defaults to: true)

    default true

  • logging (Boolean)

    (optional) logs to stdout when true

  • log_to (String)

    (optional) file path to log to file (logging must be true)



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/synapse_pay_rest/client.rb', line 31

def initialize(client_id:, client_secret:, ip_address:, fingerprint: nil,
               development_mode: true, **options)
  base_url = if development_mode
               'https://uat-api.synapsefi.com/v3.1'
             else
               'https://api.synapsefi.com/v3.1'
             end

  @http_client  = HTTPClient.new(base_url: base_url,
                                 client_id: client_id,
                                 client_secret: client_secret,
                                 fingerprint: fingerprint,
                                 ip_address: ip_address,
                                 **options)
  @users            = Users.new @http_client
  @nodes            = Nodes.new @http_client
  @subnets          = Subnets.new @http_client
  @transactions     = Transactions.new @http_client
  @subscriptions    = Subscriptions.new @http_client
  @institutions     = Institutions.new @http_client
  @client_endpoint  = ClientEndpoint.new @http_client
  @atms             = Atms.new @http_client
  @crypto_quotes    = CryptoQuotes.new @http_client
  @statements       = Statements.new @http_client
end

Instance Attribute Details

#atmsObject

Returns the value of attribute atms.



16
17
18
# File 'lib/synapse_pay_rest/client.rb', line 16

def atms
  @atms
end

#client_endpointObject

Returns the value of attribute client_endpoint.



16
17
18
# File 'lib/synapse_pay_rest/client.rb', line 16

def client_endpoint
  @client_endpoint
end

#crypto_quotesObject

Returns the value of attribute crypto_quotes.



16
17
18
# File 'lib/synapse_pay_rest/client.rb', line 16

def crypto_quotes
  @crypto_quotes
end

#http_clientSynapsePayRest::HTTPClient Also known as: client



16
17
18
# File 'lib/synapse_pay_rest/client.rb', line 16

def http_client
  @http_client
end

#institutionsObject

Returns the value of attribute institutions.



16
17
18
# File 'lib/synapse_pay_rest/client.rb', line 16

def institutions
  @institutions
end

#nodesSynapsePayRest::Nodes



16
17
# File 'lib/synapse_pay_rest/client.rb', line 16

attr_accessor :http_client, :users, :nodes, :subnets, :transactions, :subscriptions, :institutions,
:client_endpoint, :atms, :crypto_quotes, :statements

#statementsObject

Returns the value of attribute statements.



16
17
18
# File 'lib/synapse_pay_rest/client.rb', line 16

def statements
  @statements
end

#subnetsObject

Returns the value of attribute subnets.



16
17
18
# File 'lib/synapse_pay_rest/client.rb', line 16

def subnets
  @subnets
end

#subscriptionsSynapsePayRest::Subscriptions



16
17
# File 'lib/synapse_pay_rest/client.rb', line 16

attr_accessor :http_client, :users, :nodes, :subnets, :transactions, :subscriptions, :institutions,
:client_endpoint, :atms, :crypto_quotes, :statements

#transactionsSynapsePayRest::Transactions Also known as: trans



16
17
# File 'lib/synapse_pay_rest/client.rb', line 16

attr_accessor :http_client, :users, :nodes, :subnets, :transactions, :subscriptions, :institutions,
:client_endpoint, :atms, :crypto_quotes, :statements

#usersSynapsePayRest::Users



16
17
# File 'lib/synapse_pay_rest/client.rb', line 16

attr_accessor :http_client, :users, :nodes, :subnets, :transactions, :subscriptions, :institutions,
:client_endpoint, :atms, :crypto_quotes, :statements

Instance Method Details

#get_crypto_quotesObject



63
64
65
# File 'lib/synapse_pay_rest/client.rb', line 63

def get_crypto_quotes()
  CryptoQuote.get(client: self)
end

#issue_public_key(scope: "OAUTH|POST,USERS|POST,USERS|GET,USER|GET,USER|PATCH,SUBSCRIPTIONS|GET,SUBSCRIPTIONS|POST,SUBSCRIPTION|GET,SUBSCRIPTION|PATCH,CLIENT|REPORTS,CLIENT|CONTROLS") ⇒ Object



59
60
61
# File 'lib/synapse_pay_rest/client.rb', line 59

def issue_public_key(scope: "OAUTH|POST,USERS|POST,USERS|GET,USER|GET,USER|PATCH,SUBSCRIPTIONS|GET,SUBSCRIPTIONS|POST,SUBSCRIPTION|GET,SUBSCRIPTION|PATCH,CLIENT|REPORTS,CLIENT|CONTROLS")
  PublicKey.issue(client: self, scope: scope)
end