Class: ItemBuilderMwh::Modes::Simple::Base
- Inherits:
-
Object
- Object
- ItemBuilderMwh::Modes::Simple::Base
show all
- Defined in:
- lib/item_builder_mwh/modes/simple/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(listing, available_quantity) ⇒ Base
Returns a new instance of Base.
14
15
16
17
18
19
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 14
def initialize(listing, available_quantity)
raise 'listing is not set' if listing.nil?
@listing = listing
@available_quantity = available_quantity
end
|
Instance Attribute Details
#available_quantity ⇒ Object
Returns the value of attribute available_quantity.
12
13
14
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 12
def available_quantity
@available_quantity
end
|
#listing ⇒ Object
Returns the value of attribute listing.
11
12
13
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 11
def listing
@listing
end
|
Instance Method Details
#api_data ⇒ Object
59
60
61
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 59
def api_data
data.to_json
end
|
#apigateway_get ⇒ Object
35
36
37
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 35
def apigateway_get
RestClient.get("#{host}?#{params}")
end
|
#apigateway_post ⇒ Object
68
69
70
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 68
def apigateway_post
RestClient.post(url, api_data, )
end
|
#credential ⇒ Object
46
47
48
49
50
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 46
def credential
account_id = listing.profile_channel_association_id
host = ENV['CREDENTIAL_URL'] || 'user.forstok.com'
RestClient.get("#{host}/credential?account_id=#{account_id}")
end
|
#data ⇒ Object
52
53
54
55
56
57
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 52
def data
{
"credential": JSON.parse(credential)['credential'],
"data": request
}
end
|
39
40
41
42
43
44
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 39
def
{
content_type: :json,
accept: :json
}
end
|
#order_host ⇒ Object
21
22
23
24
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 21
def order_host
url = ENV['ORDERS_URL'] || 'orders.forstok.com'
url + '/api/v2/item_line/reserved_stock'
end
|
#reserved_params ⇒ Object
26
27
28
29
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 26
def reserved_params
"account_id=#{listing.profile_channel_association_id}
&item_variant_id=#{listing.variant_id}"
end
|
#reserved_stock ⇒ Object
31
32
33
|
# File 'lib/item_builder_mwh/modes/simple/base.rb', line 31
def reserved_stock
RestClient.get("#{order_host}?#{reserved_params}")
end
|
#sale_price_policy ⇒ Object