class Promisepay::UserResource

Resource for the Users API

Public Instance Methods

create(attributes) click to toggle source

Create a new user for a marketplace

@see reference.promisepay.com/#create-user

@param attributes [Hash] User's attributes.

@return [Promisepay::User]

# File lib/promisepay/resources/user_resource.rb, line 42
def create(attributes)
  response = JSON.parse(@client.post('users', attributes).body)
  Promisepay::User.new(@client, response['users'])
end
find(id) click to toggle source

Get a single user

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

@param id [String] Marketplace user ID.

@return [Promisepay::User]

# File lib/promisepay/resources/user_resource.rb, line 30
def find(id)
  response = JSON.parse(@client.get("users/#{id}").body)
  Promisepay::User.new(@client, response['users'])
end
find_all(options = {}) click to toggle source

List all users for a marketplace

@see reference.promisepay.com/#list-users

@param options [Hash] Optional options. @option options [Integer] :limit Can ask for up to 200 users. default: 10 @option options [Integer] :offset Pagination help. default: 0

@return [Array<Promisepay::User>] List all users for a marketplace.

# File lib/promisepay/resources/user_resource.rb, line 17
def find_all(options = {})
  response = JSON.parse(@client.get('users', options).body)
  users = response.key?('users') ? response['users'] : []
  users.map { |attributes| Promisepay::User.new(@client, attributes) }
end
model() click to toggle source
# File lib/promisepay/resources/user_resource.rb, line 4
def model
  Promisepay::User
end
update(attributes) click to toggle source

Update a user for a marketplace

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

@param attributes [Hash] User's attributes.

@return [Promisepay::User]

# File lib/promisepay/resources/user_resource.rb, line 54
def update(attributes)
  response = JSON.parse(@client.patch("users/#{attributes[:id]}", attributes).body)
  Promisepay::User.new(@client, response['users'])
end