Class: SynapsePay::Client
- Defined in:
- lib/synapse_pay/client.rb
Instance Attribute Summary collapse
-
#expires_in ⇒ Object
readonly
Returns the value of attribute expires_in.
-
#json ⇒ Object
readonly
Returns the value of attribute json.
-
#oauth_consumer_key ⇒ Object
readonly
Returns the value of attribute oauth_consumer_key.
-
#refresh_token ⇒ Object
readonly
Returns the value of attribute refresh_token.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Attributes inherited from APIClient
Class Method Summary collapse
Instance Method Summary collapse
- #bank_mfa_devices ⇒ Object
- #bank_mfa_questions ⇒ Object
- #bank_statuses ⇒ Object
- #banks ⇒ Object
- #cards ⇒ Object
- #deposits ⇒ Object
-
#initialize(oauth_consumer_key = nil, refresh_token = nil) ⇒ Client
constructor
A new instance of Client.
- #mass_pays ⇒ Object
- #orders ⇒ Object
- #refresh_access(refresh_token = nil) ⇒ Object
- #refresh_from(json) ⇒ Object
- #user ⇒ Object
- #wires ⇒ Object
- #withdrawals ⇒ Object
Methods inherited from APIClient
Constructor Details
#initialize(oauth_consumer_key = nil, refresh_token = nil) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 |
# File 'lib/synapse_pay/client.rb', line 11 def initialize(oauth_consumer_key=nil, refresh_token=nil) self.refresh_from({ :oauth_consumer_key => oauth_consumer_key, :refresh_token => refresh_token }) end |
Instance Attribute Details
#expires_in ⇒ Object (readonly)
Returns the value of attribute expires_in.
3 4 5 |
# File 'lib/synapse_pay/client.rb', line 3 def expires_in @expires_in end |
#json ⇒ Object (readonly)
Returns the value of attribute json.
3 4 5 |
# File 'lib/synapse_pay/client.rb', line 3 def json @json end |
#oauth_consumer_key ⇒ Object (readonly)
Returns the value of attribute oauth_consumer_key.
3 4 5 |
# File 'lib/synapse_pay/client.rb', line 3 def oauth_consumer_key @oauth_consumer_key end |
#refresh_token ⇒ Object (readonly)
Returns the value of attribute refresh_token.
3 4 5 |
# File 'lib/synapse_pay/client.rb', line 3 def refresh_token @refresh_token end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
3 4 5 |
# File 'lib/synapse_pay/client.rb', line 3 def user_id @user_id end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
3 4 5 |
# File 'lib/synapse_pay/client.rb', line 3 def username @username end |
Class Method Details
.login(username, password) ⇒ Object
30 31 32 33 34 35 36 |
# File 'lib/synapse_pay/client.rb', line 30 def self.login(username, password) method = APIMethod.new( :post, "/user/login", { :username => username, :password => password }, {}, self) self.new.refresh_from(method.execute) end |
.refresh_access(refresh_token) ⇒ Object
39 40 41 42 |
# File 'lib/synapse_pay/client.rb', line 39 def self.refresh_access(refresh_token) c = Client.new(nil, refresh_token) c.refresh_access end |
Instance Method Details
#bank_mfa_devices ⇒ Object
60 61 62 |
# File 'lib/synapse_pay/client.rb', line 60 def bank_mfa_devices @bank_mfa_devices ||= BankMfaDeviceEndpoint.new(self) end |
#bank_mfa_questions ⇒ Object
64 65 66 |
# File 'lib/synapse_pay/client.rb', line 64 def bank_mfa_questions @bank_mfa_questions ||= BankMfaQuestionsEndpoint.new(self) end |
#bank_statuses ⇒ Object
68 69 70 |
# File 'lib/synapse_pay/client.rb', line 68 def bank_statuses @bank_statuses ||= BankStatusEndpoint.new(self) end |
#banks ⇒ Object
56 57 58 |
# File 'lib/synapse_pay/client.rb', line 56 def banks @banks ||= BankEndpoint.new(self) end |
#cards ⇒ Object
72 73 74 |
# File 'lib/synapse_pay/client.rb', line 72 def cards @cards ||= CardEndpoint.new(self) end |
#deposits ⇒ Object
76 77 78 |
# File 'lib/synapse_pay/client.rb', line 76 def deposits @deposits ||= DepositEndpoint.new(self) end |
#mass_pays ⇒ Object
80 81 82 |
# File 'lib/synapse_pay/client.rb', line 80 def mass_pays @mass_pays ||= MassPayEndpoint.new(self) end |
#orders ⇒ Object
84 85 86 |
# File 'lib/synapse_pay/client.rb', line 84 def orders @orders ||= OrderEndpoint.new(self) end |
#refresh_access(refresh_token = nil) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/synapse_pay/client.rb', line 44 def refresh_access(refresh_token=nil) method = APIMethod.new( :post, "/user/refresh", { :refresh_token => refresh_token || @refresh_token }, {}, self) self.refresh_from(method.execute) end |
#refresh_from(json) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/synapse_pay/client.rb', line 18 def refresh_from(json) @json = Util.symbolize_keys(json) @oauth_consumer_key = @json[:oauth_consumer_key] @refresh_token = @json[:refresh_token] @expires_in = @json[:expires_in] @username = @json[:username] @user_id = @json[:user_id] super({}, { :oauth_consumer_key => oauth_consumer_key }) end |
#user ⇒ Object
52 53 54 |
# File 'lib/synapse_pay/client.rb', line 52 def user @user ||= UserEndpoint.new(self) end |
#wires ⇒ Object
88 89 90 |
# File 'lib/synapse_pay/client.rb', line 88 def wires @wires ||= WireEndpoint.new(self) end |
#withdrawals ⇒ Object
92 93 94 |
# File 'lib/synapse_pay/client.rb', line 92 def withdrawals @withdrawals ||= WithdrawalEndpoint.new(self) end |