class Promisepay::ItemResource
Resource for the Items API
Public Instance Methods
create(attributes)
click to toggle source
Create an item for a marketplace
@see reference.promisepay.com/#create-item
@param attributes [Hash] Item's attributes.
@return [Promisepay::Item]
# File lib/promisepay/resources/item_resource.rb, line 48 def create(attributes) response = JSON.parse(@client.post('items', attributes).body) Promisepay::Item.new(@client, response['items']) end
find(id, type = :full)
click to toggle source
Get a single item for a marketplace
@see reference.promisepay.com/#show-item
@param id [String] Marketplace item ID.
@return [Promisepay::Item]
# File lib/promisepay/resources/item_resource.rb, line 30 def find(id, type = :full) case type when :full response = JSON.parse(@client.get("items/#{id}").body) Promisepay::Item.new(@client, response['items']) when :status response = JSON.parse(@client.get("items/#{id}/status").body) Promisepay::Item.new(@client, response['items']) end end
find_all(options = {})
click to toggle source
List all items for a marketplace
@see reference.promisepay.com/#list-items
@param options [Hash] Optional options. @option options [Integer] :limit Can ask for up to 200 items. default: 10 @option options [Integer] :offset Pagination help. default: 0
@return [Array<Promisepay::Item>] List all items for a marketplace.
# File lib/promisepay/resources/item_resource.rb, line 17 def find_all(options = {}) response = JSON.parse(@client.get('items', options).body) items = response.key?('items') ? response['items'] : [] items.map { |attributes| Promisepay::Item.new(@client, attributes) } end
model()
click to toggle source
# File lib/promisepay/resources/item_resource.rb, line 4 def model Promisepay::Item end