class PandaPay::Grant

Attributes

amount[R]
created[R]
currency[R]
destination[R]
id[R]
livemode[R]
object[R]
restriction[R]
status[R]
type[R]

Public Class Methods

create(amount: , destination: , restricted: "", currency: "USD") click to toggle source
# 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
new(attributes) click to toggle source
# 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