Class: Ecommerce::Resources::Order

Inherits:
Base
  • Object
show all
Defined in:
lib/ecommerce/resources/order.rb

Overview

A wrapper to Ecommerce orders API

API

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

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Base

client, #initialize

Constructor Details

This class inherits a constructor from Ecommerce::Resources::Base

Instance Attribute Details

#activated_atObject (readonly)

Returns the value of attribute activated_at.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def activated_at
  @activated_at
end

#activation_expiredObject (readonly)

Returns the value of attribute activation_expired.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def activation_expired
  @activation_expired
end

#active_untilObject (readonly)

Returns the value of attribute active_until.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def active_until
  @active_until
end

#addressObject (readonly)

Returns the value of attribute address.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def address
  @address
end

#address_cityObject (readonly)

Returns the value of attribute address_city.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def address_city
  @address_city
end

#address_complementObject (readonly)

Returns the value of attribute address_complement.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def address_complement
  @address_complement
end

#address_numberObject (readonly)

Returns the value of attribute address_number.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def address_number
  @address_number
end

#address_quarterObject (readonly)

Returns the value of attribute address_quarter.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def address_quarter
  @address_quarter
end

#address_stateObject (readonly)

Returns the value of attribute address_state.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def address_state
  @address_state
end

#adjustments_urlObject (readonly)

Returns the value of attribute adjustments_url.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def adjustments_url
  @adjustments_url
end

#amountObject (readonly)

Returns the value of attribute amount.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def amount
  @amount
end

#api_urlObject (readonly)

Returns the value of attribute api_url.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def api_url
  @api_url
end

#charge_dayObject (readonly)

Returns the value of attribute charge_day.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def charge_day
  @charge_day
end

#checkout_urlObject (readonly)

Returns the value of attribute checkout_url.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def checkout_url
  @checkout_url
end

#client_emailObject (readonly)

Returns the value of attribute client_email.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def client_email
  @client_email
end

#client_nameObject (readonly)

Returns the value of attribute client_name.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def client_name
  @client_name
end

#created_atObject (readonly)

Returns the value of attribute created_at.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def created_at
  @created_at
end

#discounts_urlObject (readonly)

Returns the value of attribute discounts_url.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def discounts_url
  @discounts_url
end

#document_numberObject (readonly)

Returns the value of attribute document_number.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def document_number
  @document_number
end

#global_accountObject (readonly)

Returns the value of attribute global_account.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def 
  @global_account
end

#invoices_urlObject (readonly)

Returns the value of attribute invoices_url.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def invoices_url
  @invoices_url
end

#is_activeObject (readonly)

Returns the value of attribute is_active.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def is_active
  @is_active
end

#is_paidObject (readonly)

Returns the value of attribute is_paid.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def is_paid
  @is_paid
end

#is_recurringObject (readonly)

Returns the value of attribute is_recurring.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def is_recurring
  @is_recurring
end

#is_trialObject (readonly)

Returns the value of attribute is_trial.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def is_trial
  @is_trial
end

#next_payment_atObject (readonly)

Returns the value of attribute next_payment_at.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def next_payment_at
  @next_payment_at
end

#numberObject (readonly)

Returns the value of attribute number.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def number
  @number
end

#plan_change_urlsObject (readonly)

Returns the value of attribute plan_change_urls.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def plan_change_urls
  @plan_change_urls
end

#plan_slugObject (readonly)

Returns the value of attribute plan_slug.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def plan_slug
  @plan_slug
end

#user_codeObject (readonly)

Returns the value of attribute user_code.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def user_code
  @user_code
end

#zip_codeObject (readonly)

Returns the value of attribute zip_code.



10
11
12
# File 'lib/ecommerce/resources/order.rb', line 10

def zip_code
  @zip_code
end

Class Method Details

.create(slug, params) ⇒ Object

Creates an Order

API

Method: POST /api/orders/:slug/

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



24
25
26
27
28
# File 'lib/ecommerce/resources/order.rb', line 24

def self.create(slug, params)
  client.post("/api/orders/#{slug}/", body: params) do |response|
    build_order(response)
  end
end

.destroy(order_id, slug) ⇒ Object

Destroys an Order

API

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

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#delete-api-orders-slug-id



68
69
70
71
72
# File 'lib/ecommerce/resources/order.rb', line 68

def self.destroy(order_id, slug)
  client.delete("/api/orders/#{slug}/#{order_id}/") do |response|
    build_order(response)
  end
end

.find(order_id, slug) ⇒ Object

Finds an Order

API

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

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#detalhes-de-uma-ordem-de-compra



54
55
56
57
58
# File 'lib/ecommerce/resources/order.rb', line 54

def self.find(order_id, slug)
  client.get("/api/orders/#{slug}/#{order_id}/") do |response|
    build_order(response)
  end
end

.find_all(slug, page = 1, limit = 20) ⇒ Object

Lists all Orders of a slug and return a collection with orders and pagination information (represented by Ecommerce::Resources::OrderCollection)

API

Method: GET /api/orders/:slug/

Documentation: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#listagem-de-ordens-de-compra



39
40
41
42
43
44
# File 'lib/ecommerce/resources/order.rb', line 39

def self.find_all(slug, page = 1, limit = 20)
  body = { page: page, limit: limit }
  client.get("/api/orders/#{slug}/", body: body) do |response|
    Ecommerce::Resources::OrderCollection.build(response)
  end
end

.update(order_id, slug, order_params = {}) ⇒ Object

Updates an Order client information

API

Method: PUT /api/orders/:slug/:order_id/

Documentation for available and required fields: myfreecomm.github.io/passaporte-web/ecommerce/api/orders.html#put-api-orders-slug-id



82
83
84
85
86
# File 'lib/ecommerce/resources/order.rb', line 82

def self.update(order_id, slug, order_params={})
  client.put("/api/orders/#{slug}/#{order_id}/", body: order_params) do |response|
    build_order(response)
  end
end