class Promisepay::CompanyResource

Resource for the Fees API

Public Instance Methods

create(attributes) click to toggle source

Create a company for a user

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

@param attributes [Hash] Company's attributes.

@return [Promisepay::Company]

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

Get a company

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

@param id [String] Company id

@return [Promisepay::Company]

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

List all companies for a marketplace

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

@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::Company>] List all companies for a marketplace.

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

Update a company for a user

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

@param attributes [Hash] Company's attributes.

@return [Promisepay::Company]

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