class Ecommerce::Resources::AdjustmentOrder

A wrapper to Ecommerce adjusments orders API

API

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/index.html

Attributes

amount[R]
description[R]
url[R]
valid_from[R]
valid_until[R]

Public Class Methods

build(response) click to toggle source
# File lib/ecommerce/resources/adjustment_order.rb, line 77
def self.build(response)
  attributes = parsed_body(response)
  attributes.empty? ? {} : new(attributes)
end
create(slug, order_id, params) click to toggle source

Creates an Adjustment order

API

Method: POST /api/orders/:slug/:id/adjustments/

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#criacao-de-alteracao-de-valor-para-uma-ordem-de-compra

# File lib/ecommerce/resources/adjustment_order.rb, line 27
def self.create(slug, order_id, params)
  client.post("/api/orders/#{slug}/#{order_id}/adjustments/", body: params) do |response|
    build(response)
  end
end
destroy(order_id, slug, id) click to toggle source

Destroys an Adjustment order

API

Method: DELETE /api/orders/:slug/:order_id/adjustments/:id/

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#remocao-de-uma-alteracao-de-valor

# File lib/ecommerce/resources/adjustment_order.rb, line 71
def self.destroy(order_id, slug, id)
  client.delete("/api/orders/#{slug}/#{order_id}/adjustments/#{id}/") do |response|
    build(response)
  end
end
find(slug, order_id, id) click to toggle source

Finds an Adjustment order

API

Method: GET /api/orders/:slug/:order_id/adjustments/:id/

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#obtencao-dos-dados-de-uma-alteracao-de-valor

# File lib/ecommerce/resources/adjustment_order.rb, line 57
def self.find(slug, order_id, id)
  client.get("/api/orders/#{slug}/#{order_id}/adjustments/#{id}/") do |response|
    build(response)
  end
end
find_all(slug, order_id, page = 1, limit = 20) click to toggle source

Lists all Adjustments orders of an order and return a collection and pagination information (represented by Ecommerce::Resources::AdjustmentOrderCollection)

API

Method: GET /api/orders/:slug/adjustments/

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#listagem-das-alteracoes-de-valor-associadas-a-uma-ordem-de-compra

# File lib/ecommerce/resources/adjustment_order.rb, line 42
def self.find_all(slug, order_id, page = 1, limit = 20)
  body = { page: page, limit: limit }
  client.get("/api/orders/#{slug}/#{order_id}/adjustments/", body: body) do |response|
    Ecommerce::Resources::AdjustmentOrderCollection.build(response)
  end
end

Public Instance Methods

id() click to toggle source

Adjustment order API does not return the ID field

# File lib/ecommerce/resources/adjustment_order.rb, line 15
def id
  url.split('/')[8].to_i
end