Class: Iugu::Account

Inherits:
APIResource show all
Defined in:
lib/iugu/account.rb

Instance Attribute Summary

Attributes inherited from Object

#attributes, #errors, #unsaved_attributes

Class Method Summary collapse

Methods inherited from APIResource

endpoint_url, #is_new?, object_base_uri, object_type, relative_url, url

Methods inherited from Object

#add_accessor, #copy, #initialize, #method_missing, #modified_attributes, #set_attributes

Constructor Details

This class inherits a constructor from Iugu::Object

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Iugu::Object

Class Method Details

.bank(attributes, user_token) ⇒ Object

POST /bank_verification

Update a bank account

Parameters:

  • attributes (Hash)

    the values to update an bank account

  • user_token (String)

    of the account

Options Hash (attributes):

  • :agency (Integer)

    The number of agency

  • :account (Integer)

    The number of account

  • :account_type (String)

    The type of account

  • :bank (Integer)

    The number of the bank account

  • :document (file)

    Documento for comprove the data of bank account



177
178
179
180
181
182
183
184
185
186
187
# File 'lib/iugu/account.rb', line 177

def self.bank(attributes, user_token)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "POST",
      "#{Iugu.base_uri}bank_verification",
      attributes,
      user_token
    )
  )
end

.banks(user_token) ⇒ Object

GET /bank_verification

List bank accounts

Parameters:

  • user_token (String)

    of the account



195
196
197
198
199
200
201
202
203
204
205
# File 'lib/iugu/account.rb', line 195

def self.banks(user_token)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "GET",
      "#{Iugu.base_uri}bank_verification",
      {},
      user_token
    )
  )
end

.configuration(attributes, api_token) ⇒ Object

Configures a account POST /accounts/configuration



110
111
112
113
114
115
116
117
118
119
120
# File 'lib/iugu/account.rb', line 110

def self.configuration(attributes, api_token)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "POST",
      "#{url}/configuration",
      attributes,
      api_token
    )
  )
end

.create(attributes) ⇒ Object

POST /marketplace/create_account

Creates a account

Parameters:

  • attributes (Hash)

    the values to create an account

Options Hash (attributes):

  • :name (String)

    The name of an account

  • :commission_percent (Integer)

    The commission_percent of an account



14
15
16
17
18
19
20
21
22
23
# File 'lib/iugu/account.rb', line 14

def self.create(attributes)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "POST",
      "#{Iugu.base_uri}marketplace/create_account",
      attributes
    )
  )
end

.fetch(account_id, user_token) ⇒ Object

GET /accounts/:account_id

Searchs a account

Parameters:

  • account_id (String)

    the account_id of an account

  • user_token (String)

    the user_token of an account



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/iugu/account.rb', line 95

def self.fetch(, user_token)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "GET",
      "#{url()}",
      {},
      user_token
    )
  )
end

.transfer(attributes, api_token) ⇒ Object

POST /accounts/transfers

Transfers an amount to another account

Parameters:

  • attributes (Hash)

    the values to make a transfer of an account

  • api_token (String)

    live_api_token of the account sending the money

  • attributes[receiver_id] (Hash)

    a customizable set of options

  • attributes[amount_cents] (Hash)

    a customizable set of options



131
132
133
134
135
136
137
138
139
140
141
# File 'lib/iugu/account.rb', line 131

def self.transfer(attributes, api_token)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "POST",
      "#{Iugu.base_uri}transfers",
      attributes,
      api_token
    )
  )
end

.verify(attributes, account_id, user_token) ⇒ Object

POST /accounts/:account_id/request_verification

Verify a account

'Mais que R$ 500,00']

Parameters:

  • attributes (Hash)

    the values to verify an account, divided into two hashes, [data] and [file]

  • account_id (String)

    the account_id of an account

  • user_token (String)

    the user_token of an account

  • attributes[data] (Hash)

    a customizable set of options

  • attributes[file] (Hash)

    a customizable set of options



76
77
78
79
80
81
82
83
84
85
86
# File 'lib/iugu/account.rb', line 76

def self.verify(attributes, , user_token)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "POST",
      "#{url()}/request_verification",
      attributes,
      user_token
    )
  )
end

.withdraw(attributes, account_id, user_token) ⇒ Object

POST /accounts/:account_id/request_withdraw

Withdraw a value of an account

Parameters:

  • attributes (Hash)

    the values to make a withdrawal of an account

  • account_id (String)

    the account_id of an account

  • user_token (String)

    the user_token of an account

Options Hash (attributes):

  • :amount (Float)

    the amount defines the value of withdrawal



153
154
155
156
157
158
159
160
161
162
163
# File 'lib/iugu/account.rb', line 153

def self.withdraw(attributes, , user_token)
  Iugu::Factory.create_from_response(
    object_type,
    APIRequest.request(
      "POST",
      "#{url()}/request_withdraw",
      attributes,
      user_token
    )
  )
end