Class: SynapsePayRest::Institution
- Inherits:
-
Object
- Object
- SynapsePayRest::Institution
- Defined in:
- lib/synapse_pay_rest/models/institution/institution.rb
Overview
Represents an institution record and holds methods for getting institution instances from API calls. This is built on top of the SynapsePayRest::Institution class and is intended to make it easier to use the API without knowing payload formats or knowledge of REST.
Instance Attribute Summary collapse
-
#bank_code ⇒ Object
readonly
Returns the value of attribute bank_code.
-
#bank_name ⇒ Object
readonly
Returns the value of attribute bank_name.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#features ⇒ Object
readonly
Returns the value of attribute features.
-
#forgotten_password ⇒ Object
readonly
Returns the value of attribute forgotten_password.
-
#is_active ⇒ Object
readonly
Returns the value of attribute is_active.
-
#logo ⇒ Object
readonly
Returns the value of attribute logo.
-
#tx_history_months ⇒ Object
readonly
Returns the value of attribute tx_history_months.
Class Method Summary collapse
- .all(client:) ⇒ Object
-
.from_response(client, response) ⇒ Object
Creates an Institution from a response hash.
-
.multiple_from_response(client, response) ⇒ Object
Calls from_response on each member of a response collection.
Instance Method Summary collapse
-
#initialize(**options) ⇒ Institution
constructor
A new instance of Institution.
Constructor Details
#initialize(**options) ⇒ Institution
Do not call directly. Use other class method to instantiate via API action.
Returns a new instance of Institution.
45 46 47 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 45 def initialize(**) .each { |key, value| instance_variable_set("@#{key}", value) } end |
Instance Attribute Details
#bank_code ⇒ Object (readonly)
Returns the value of attribute bank_code.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def bank_code @bank_code end |
#bank_name ⇒ Object (readonly)
Returns the value of attribute bank_name.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def bank_name @bank_name end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def client @client end |
#features ⇒ Object (readonly)
Returns the value of attribute features.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def features @features end |
#forgotten_password ⇒ Object (readonly)
Returns the value of attribute forgotten_password.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def forgotten_password @forgotten_password end |
#is_active ⇒ Object (readonly)
Returns the value of attribute is_active.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def is_active @is_active end |
#logo ⇒ Object (readonly)
Returns the value of attribute logo.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def logo @logo end |
#tx_history_months ⇒ Object (readonly)
Returns the value of attribute tx_history_months.
8 9 10 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 8 def tx_history_months @tx_history_months end |
Class Method Details
.all(client:) ⇒ Object
29 30 31 32 33 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 29 def all(client:) raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client) response = client.institutions.get() multiple_from_response(client, response['banks']) end |
.from_response(client, response) ⇒ Object
Shouldn’t need to call this directly.
Creates an Institution from a response hash.
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 15 def from_response(client, response) args = { client: client, bank_code: response['bank_code'], bank_name: response['bank_name'], features: response['features'], forgotten_password: response['forgotten_password'], is_active: response['is_active'], logo: response['logo'], tx_history_months: response['tx_history_months'] } self.new(args) end |
.multiple_from_response(client, response) ⇒ Object
Calls from_response on each member of a response collection.
36 37 38 39 |
# File 'lib/synapse_pay_rest/models/institution/institution.rb', line 36 def multiple_from_response(client, response) return [] if response.empty? response.map { |institution_data| from_response(client.dup, institution_data)} end |