Class: ProxyCheapClient::Order
- Defined in:
- lib/proxy_cheap_client/models/order.rb
Overview
module Models
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
-
#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 = {}, client) ⇒ Order
constructor
A new instance of Order.
-
#proxies ⇒ Order
Get proxies of an order.
-
#to_h ⇒ Object
initialize.
Methods inherited from Base
#extract_error_body, #extract_error_message, #parse_response, #request
Constructor Details
#initialize(attrs = {}, client) ⇒ Order
Returns a new instance of Order.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/proxy_cheap_client/models/order.rb', line 13 def initialize(attrs = {}, client) @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"] @conn = client.conn end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
4 5 6 |
# File 'lib/proxy_cheap_client/models/order.rb', line 4 def conn @conn end |
#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
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/proxy_cheap_client/models/order.rb', line 38 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
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/proxy_cheap_client/models/order.rb', line 24 def to_h { id: id, #status: status, #proxies: proxies, #created_at: created_at, total_price: total_price, #currency: currency } end |