Class: PandaPay::Grant

Inherits:
Object
  • Object
show all
Defined in:
lib/pandapay/grant.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#amountObject (readonly)

Returns the value of attribute amount.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def amount
  @amount
end

#createdObject (readonly)

Returns the value of attribute created.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def created
  @created
end

#currencyObject (readonly)

Returns the value of attribute currency.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def currency
  @currency
end

#destinationObject (readonly)

Returns the value of attribute destination.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def destination
  @destination
end

#idObject (readonly)

Returns the value of attribute id.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def id
  @id
end

#livemodeObject (readonly)

Returns the value of attribute livemode.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def livemode
  @livemode
end

#objectObject (readonly)

Returns the value of attribute object.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def object
  @object
end

#restrictionObject (readonly)

Returns the value of attribute restriction.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def restriction
  @restriction
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/pandapay/grant.rb', line 4

def status
  @status
end

#typeObject (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