class Bond::Order
Attributes
created_at[RW]
guid[RW]
links[RW]
products[RW]
shipping[RW]
status[RW]
total[RW]
Public Class Methods
all(options = {})
click to toggle source
@param [Hash] options @return [Array<Bond::Order>]
# File lib/bond/order.rb, line 11 def all(options = {}) page = options[:page] response = Bond::Connection.connection.get("/orders?page=#{page || 1}") JSON.parse(response.body)['data'].map do |attributes| new(attributes) end end
create()
click to toggle source
@return [Bond::Order]
# File lib/bond/order.rb, line 37 def create response = Bond::Connection.connection.post('/orders') json = JSON.parse(response.body) Bond::BondError.handle_errors(json) attributes = json['data'] new(attributes) end
find(guid)
click to toggle source
@param [String] guid @return [Bond::Order]
# File lib/bond/order.rb, line 30 def find(guid) response = Bond::Connection.connection.get("/orders/#{guid}") attributes = JSON.parse(response.body)['data'] new(attributes) end
new(attributes = {})
click to toggle source
@param [Hash] attributes
# File lib/bond/order.rb, line 49 def initialize(attributes = {}) attributes.each { |name, value| instance_variable_set("@#{name}", value) } end
pagination()
click to toggle source
@return [Hash]
# File lib/bond/order.rb, line 21 def pagination @pagination ||= begin response = Bond::Connection.connection.get('/orders') JSON.parse(response.body)['pagination'] || {} end end
Public Instance Methods
add_message(message_hash)
click to toggle source
@param [Hash] message_hash @return [Boolean]
# File lib/bond/order.rb, line 68 def add_message(message_hash) response = Bond::Connection.connection.post("/orders/#{guid}/messages", message_hash) @messages = nil response.success? end
message_pagination()
click to toggle source
@return [Hash]
# File lib/bond/order.rb, line 87 def message_pagination @message_pagination ||= begin response = Bond::Connection.connection.get("/orders/#{guid}/messages") JSON.parse(response.body)['pagination'] || {} end end
messages()
click to toggle source
@return [Array<Bond::Message>]
# File lib/bond/order.rb, line 76 def messages @messages ||= begin response = Bond::Connection.connection.get("/orders/#{guid}/messages") messages = JSON.parse(response.body)['data'] messages.map do |attributes| Message.new(attributes) end end end
process()
click to toggle source
@return [Boolean]
# File lib/bond/order.rb, line 54 def process response = Bond::Connection.connection.post("/orders/#{guid}/process") json = JSON.parse(response.body) Bond::BondError.handle_errors(json) attributes = json['data'] attributes.each { |name, value| instance_variable_set("@#{name}", value) } self.links = json['links'] response.success? end