Class: PandaPay::Grant
- Inherits:
-
Object
- Object
- PandaPay::Grant
- Defined in:
- lib/pandapay/grant.rb
Instance Attribute Summary collapse
-
#amount ⇒ Object
readonly
Returns the value of attribute amount.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#livemode ⇒ Object
readonly
Returns the value of attribute livemode.
-
#object ⇒ Object
readonly
Returns the value of attribute object.
-
#restriction ⇒ Object
readonly
Returns the value of attribute restriction.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(attributes) ⇒ Grant
constructor
A new instance of Grant.
Constructor Details
#initialize(attributes) ⇒ Grant
Returns a new instance of Grant.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pandapay/grant.rb', line 6 def initialize(attributes) @id = attributes["id"] @object = attributes["object"] @created = attributes["created"] @livemode = attributes["livemode"] @amount = attributes["amount"] @status = attributes["status"] @currency = attributes["currency"] @type = attributes["type"] @destination = attributes["destination"] @restriction = attributes["restriction"] end |
Instance Attribute Details
#amount ⇒ Object (readonly)
Returns the value of attribute amount.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def amount @amount end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def created @created end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def currency @currency end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def destination @destination end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def id @id end |
#livemode ⇒ Object (readonly)
Returns the value of attribute livemode.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def livemode @livemode end |
#object ⇒ Object (readonly)
Returns the value of attribute object.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def object @object end |
#restriction ⇒ Object (readonly)
Returns the value of attribute restriction.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def restriction @restriction end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def status @status end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/pandapay/grant.rb', line 4 def type @type end |
Class Method Details
.create(amount:, destination:, restricted: "", currency: "USD") ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/pandapay/grant.rb', line 19 def self.create(amount: , destination: , restricted: "", currency: "USD") conn = Faraday.new(:url => "https://#{PandaPay.secret_key}:@#{PandaPay_API_URL}") response = conn.post '/v1/grants', {:restricted => restricted, :amount => amount, :currency => currency, :destination => destination} attributes = JSON.parse(response.body) if attributes.has_key? "error" or attributes.has_key? "errors" raise response.body else new(attributes) end end |