Class: ProxyCheapClient::Order
- Defined in:
- lib/proxy_cheap_client/models/order.rb
Overview
module Models
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#total_price ⇒ Object
readonly
Returns the value of attribute total_price.
Instance Method Summary collapse
-
#initialize(attrs) ⇒ Order
constructor
:currency,.
-
#proxies ⇒ Order
Get proxies of an order.
-
#to_h ⇒ Object
initialize.
Methods inherited from Base
#conn, extract_error_body, extract_error_message, parse_response, request, #request
Constructor Details
#initialize(attrs) ⇒ Order
:currency,
12 13 14 15 16 17 18 19 20 |
# File 'lib/proxy_cheap_client/models/order.rb', line 12 def initialize(attrs) @data = attrs @id = attrs["id"] || attrs["orderId"] #@status = attrs["status"] #@proxies = attrs["proxies"] #@created_at = attrs["createdAt"] || attrs["created_at"] @total_price = attrs["totalPrice"] || attrs["total_price"] #@currency = attrs["currency"] end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
4 5 6 |
# File 'lib/proxy_cheap_client/models/order.rb', line 4 def data @data end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/proxy_cheap_client/models/order.rb', line 4 def id @id end |
#total_price ⇒ Object (readonly)
Returns the value of attribute total_price.
4 5 6 |
# File 'lib/proxy_cheap_client/models/order.rb', line 4 def total_price @total_price end |
Instance Method Details
#proxies ⇒ Order
Get proxies of an order
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/proxy_cheap_client/models/order.rb', line 36 def proxies() order_id = self.id resp = request(:get, "orders/#{order_id}/proxies") # The response may be an array or wrapped in a key (e.g. "proxies" or "data"). proxy_data = if resp.is_a?(Hash) && resp.key?("proxies") resp["proxies"] elsif resp.is_a?(Hash) && resp.key?("data") resp["data"] else resp end Array(proxy_data).map { |p| ProxyCheapClient::Proxy.new(p) } end |
#to_h ⇒ Object
initialize
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/proxy_cheap_client/models/order.rb', line 22 def to_h { id: id, #status: status, #proxies: proxies, #created_at: created_at, total_price: total_price, #currency: currency } end |