Class: Giftrocket::FundingSource

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/giftrocket/funding_source.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes) ⇒ FundingSource

Returns a new instance of FundingSource.



9
10
11
12
13
14
# File 'lib/giftrocket/funding_source.rb', line 9

def initialize(attributes)
  attributes = attributes.with_indifferent_access
  self.id = attributes[:id]
  self.method = attributes[:method]
  self.meta = attributes[:meta]
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/giftrocket/funding_source.rb', line 7

def id
  @id
end

#metaObject

Returns the value of attribute meta.



7
8
9
# File 'lib/giftrocket/funding_source.rb', line 7

def meta
  @meta
end

#methodObject

Returns the value of attribute method.



7
8
9
# File 'lib/giftrocket/funding_source.rb', line 7

def method
  @method
end

Class Method Details

.listObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/giftrocket/funding_source.rb', line 16

def self.list
  response = get '/', query: Giftrocket.default_options, format: 'json'
  if response.success?
    response_json = JSON.parse(response.body).with_indifferent_access
    response_json[:funding_sources].map do |funding_souce_attributes|
      Giftrocket::FundingSource.new(funding_souce_attributes)
    end
  else
    raise Giftrocket::Error.new(response)
  end
end