class Promisepay::User

Manage Users

Public Instance Methods

address() click to toggle source

Gets user address.

@see reference.promisepay.com/#addresses

@return [Hash]

# File lib/promisepay/models/user.rb, line 105
def address
  return nil unless @attributes.key?('related')
  response = JSON.parse(@client.get("addresses/#{send(:related)['addresses']}").body)
  response['addresses']
end
bank_account() click to toggle source

Gets Bank account for a user on a marketplace.

@see reference.promisepay.com/#show-user-bank-account

@return [Promisepay::BankAccount]

# File lib/promisepay/models/user.rb, line 34
def bank_account
  response = JSON.parse(@client.get("users/#{send(:id)}/bank_accounts").body)
  Promisepay::BankAccount.new(@client, response['bank_accounts'])
rescue Promisepay::UnprocessableEntity
  nil
end
card_account() click to toggle source

Gets Card account for a user on a marketplace.

@see reference.promisepay.com/#show-user-card-account

@return [Promisepay::CardAccount]

# File lib/promisepay/models/user.rb, line 46
def card_account
  response = JSON.parse(@client.get("users/#{send(:id)}/card_accounts").body)
  Promisepay::CardAccount.new(@client, response['card_accounts'])
rescue Promisepay::UnprocessableEntity
  nil
end
company() click to toggle source

Gets company for a user on a marketplace.

@see

@return [Promisepay::Company]

# File lib/promisepay/models/user.rb, line 93
def company
  response = JSON.parse(@client.get("users/#{send(:id)}/companies").body)
  Promisepay::Company.new(@client, response['companies'])
rescue Promisepay::NotFound
  nil
end
disbursement_account(account_id) click to toggle source

Set the disbursement account for a user.

@see reference.promisepay.com/#set-user-disbursement-account

@return [Boolean]

# File lib/promisepay/models/user.rb, line 82
def disbursement_account(account_id)
  options = { account_id: account_id }
  JSON.parse(@client.post("users/#{send(:id)}/disbursement_account", options).body)
  true
end
items() click to toggle source

Lists items for a user on a marketplace.

@see reference.promisepay.com/#list-user-items

@return [Array<Promisepay::Item>]

# File lib/promisepay/models/user.rb, line 23
def items
  response = JSON.parse(@client.get("users/#{send(:id)}/items").body)
  users = response.key?('items') ? response['items'] : []
  users.map { |attributes| Promisepay::Item.new(@client, attributes) }
end
paypal_account() click to toggle source

Gets PayPal account for a user on a marketplace.

@see reference.promisepay.com/#show-user-paypal-account

@return [Promisepay::PaypalAccount]

# File lib/promisepay/models/user.rb, line 58
def paypal_account
  response = JSON.parse(@client.get("users/#{send(:id)}/paypal_accounts").body)
  Promisepay::PaypalAccount.new(@client, response['paypal_accounts'])
rescue Promisepay::UnprocessableEntity
  nil
end
update(attributes) click to toggle source

Update the attributes of an item.

@see reference.promisepay.com/#update-item

@param attributes [Hash] Item's attributes to be updated.

@return [self]

# File lib/promisepay/models/user.rb, line 12
def update(attributes)
  response = JSON.parse(@client.patch("users/#{send(:id)}", attributes).body)
  @attributes = response['users']
  self
end
wallet_account() click to toggle source

Show the User’s Wallet Account.

@see reference.promisepay.com/#show-user-wallet-account

@return [Promisepay::WalletAccount]

# File lib/promisepay/models/user.rb, line 70
def wallet_account
  response = JSON.parse(@client.get("users/#{send(:id)}/wallet_accounts").body)
  Promisepay::WalletAccount.new(@client, response['wallet_accounts'])
rescue Promisepay::UnprocessableEntity
  nil
end