Class: MoneyMover::Dwolla::ApiResource
- Inherits:
-
Object
- Object
- MoneyMover::Dwolla::ApiResource
- Includes:
- ActiveModel::Model
- Defined in:
- lib/money_mover/dwolla/models/api_resource.rb
Direct Known Subclasses
AccountFundingSource, Customer, CustomerFundingSource, Document, MicroDepositInitiation, MicroDepositVerification, RootAccount, Transfer, WebhookSubscription
Instance Attribute Summary collapse
-
#_embedded ⇒ Object
Returns the value of attribute _embedded.
-
#_links ⇒ Object
Returns the value of attribute _links.
-
#attrs ⇒ Object
readonly
Returns the value of attribute attrs.
-
#id ⇒ Object
Returns the value of attribute id.
-
#resource_location ⇒ Object
readonly
Returns the value of attribute resource_location.
Class Method Summary collapse
Instance Method Summary collapse
- #destroy ⇒ Object
-
#initialize(attrs = {}, client = ApplicationClient.new) ⇒ ApiResource
constructor
A new instance of ApiResource.
- #save ⇒ Object
Constructor Details
#initialize(attrs = {}, client = ApplicationClient.new) ⇒ ApiResource
Returns a new instance of ApiResource.
10 11 12 13 14 15 16 17 18 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 10 def initialize(attrs = {}, client = ApplicationClient.new) @attrs = attrs @id = attrs[:id] @resource_location = attrs[:resource_location] @_links = attrs[:_links] @client = client super attrs end |
Instance Attribute Details
#_embedded ⇒ Object
Returns the value of attribute _embedded.
6 7 8 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 6 def @_embedded end |
#_links ⇒ Object
Returns the value of attribute _links.
6 7 8 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 6 def _links @_links end |
#attrs ⇒ Object (readonly)
Returns the value of attribute attrs.
8 9 10 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 8 def attrs @attrs end |
#id ⇒ Object
Returns the value of attribute id.
6 7 8 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 6 def id @id end |
#resource_location ⇒ Object (readonly)
Returns the value of attribute resource_location.
8 9 10 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 8 def resource_location @resource_location end |
Class Method Details
.fetch ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 20 def self.fetch client = ApplicationClient.new response = client.get fetch_endpoint if response.success? new response.body else #raise 'Customer Not Found' #puts "error: #{response.body}" end end |
Instance Method Details
#destroy ⇒ Object
48 49 50 51 52 53 54 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 48 def destroy response = @client.delete resource_endpoint add_errors_from response unless response.success? errors.empty? end |
#save ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/money_mover/dwolla/models/api_resource.rb', line 33 def save return false unless valid? response = @client.post create_endpoint, create_params if response.success? @resource_location = response.resource_location @id = response.resource_id else add_errors_from response end errors.empty? end |