Class: StarkInfra::IssuingRestock
- Inherits:
-
StarkCore::Utils::Resource
- Object
- StarkCore::Utils::Resource
- StarkInfra::IssuingRestock
- Defined in:
- lib/issuing_restock/issuing_restock.rb,
lib/issuing_restock/log.rb
Overview
# IssuingRestock object
The IssuingRestock object displays the information of the restock orders created in your Workspace. This resource place a restock order for a specific IssuingStock object.
## Parameters (required):
-
count [integer]: number of restocks to be restocked. ex: 100
-
stock_id [string]: IssuingStock unique id ex: “5136459887542272”
## Parameters (optional):
-
tags [list of strings, default nil]: list of strings for tagging. ex: [“card”, “corporate”]
## Attributes (return-only):
-
id [string]: unique id returned when IssuingRestock is created. ex: ‘5656565656565656’
-
status [string]: current IssuingRestock status. ex: “created”, “processing”, “confirmed”
-
updated [DateTime]: latest update datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
-
created [DateTime]: creation datetime for the IssuingRestock. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)
Defined Under Namespace
Classes: Log
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stock_id ⇒ Object
readonly
Returns the value of attribute stock_id.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#updated ⇒ Object
readonly
Returns the value of attribute updated.
Class Method Summary collapse
-
.create(restocks:, user: nil) ⇒ Object
# Create IssuingRestocks.
-
.get(id, user: nil) ⇒ Object
# Retrieve a specific IssuingRestock.
-
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil, tags: nil, user: nil) ⇒ Object
# Retrieve paged IssuingRestocks.
-
.query(limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil, tags: nil, user: nil) ⇒ Object
# Retrieve IssuingRestocks.
- .resource ⇒ Object
Instance Method Summary collapse
-
#initialize(count:, stock_id:, tags: nil, id: nil, status: nil, updated: nil, created: nil) ⇒ IssuingRestock
constructor
A new instance of IssuingRestock.
Constructor Details
#initialize(count:, stock_id:, tags: nil, id: nil, status: nil, updated: nil, created: nil) ⇒ IssuingRestock
Returns a new instance of IssuingRestock.
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/issuing_restock/issuing_restock.rb', line 26 def initialize( count:, stock_id:, tags: nil, id: nil, status: nil, updated: nil, created: nil ) super(id) @count = count @stock_id = stock_id @tags = @status = status @created = StarkCore::Utils::Checks.check_datetime(created) @updated = StarkCore::Utils::Checks.check_datetime(updated) end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
25 26 27 |
# File 'lib/issuing_restock/issuing_restock.rb', line 25 def count @count end |
#created ⇒ Object (readonly)
Returns the value of attribute created.
25 26 27 |
# File 'lib/issuing_restock/issuing_restock.rb', line 25 def created @created end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
25 26 27 |
# File 'lib/issuing_restock/issuing_restock.rb', line 25 def id @id end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
25 26 27 |
# File 'lib/issuing_restock/issuing_restock.rb', line 25 def status @status end |
#stock_id ⇒ Object (readonly)
Returns the value of attribute stock_id.
25 26 27 |
# File 'lib/issuing_restock/issuing_restock.rb', line 25 def stock_id @stock_id end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
25 26 27 |
# File 'lib/issuing_restock/issuing_restock.rb', line 25 def @tags end |
#updated ⇒ Object (readonly)
Returns the value of attribute updated.
25 26 27 |
# File 'lib/issuing_restock/issuing_restock.rb', line 25 def updated @updated end |
Class Method Details
.create(restocks:, user: nil) ⇒ Object
# Create IssuingRestocks
Send a list of IssuingRestock objects for creation in the Stark Infra API
## Parameters (required):
-
restocks [list of IssuingRestock objects]: list of IssuingRestock objects to be created in the API
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
list of IssuingRestock objects with updated attributes
50 51 52 |
# File 'lib/issuing_restock/issuing_restock.rb', line 50 def self.create(restocks:, user: nil) StarkInfra::Utils::Rest.post(entities: restocks, user: user, **resource) end |
.get(id, user: nil) ⇒ Object
# Retrieve a specific IssuingRestock
Receive a single IssuingRestock object previously created in the Stark Infra API by its id
## Parameters (required):
-
id [string]: object unique id. ex: ‘5656565656565656’
## Parameters (optional):
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
IssuingRestock object with updated attributes
66 67 68 |
# File 'lib/issuing_restock/issuing_restock.rb', line 66 def self.get(id, user: nil) StarkInfra::Utils::Rest.get_id(id: id, user: user, **resource) end |
.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil, tags: nil, user: nil) ⇒ Object
# Retrieve paged IssuingRestocks
Receive a list of up to 100 IssuingRestock objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.
## Parameters (optional):
-
cursor [string, default nil]: cursor returned on the previous page function call.
-
limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex: 35
-
after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
status [list of strings, default nil]: filter for status of retrieved objects. ex: [“created”, “processing”, “confirmed”]
-
stock_ids [list of string, default nil]: list of stock_ids to filter retrieved objects. ex: [“5656565656565656”, “4545454545454545”]
-
ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [“card”, “corporate”]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
list of IssuingRestocks objects with updated attributes
-
cursor to retrieve the next page of IssuingRestocks objects
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/issuing_restock/issuing_restock.rb', line 124 def self.page( cursor: nil, limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil, tags: nil, user: nil ) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_page( cursor: cursor, limit: limit, after: after, before: before, status: status, stock_ids: stock_ids, ids: ids, tags: , user: user, **resource ) end |
.query(limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil, tags: nil, user: nil) ⇒ Object
# Retrieve IssuingRestocks
Receive a generator of IssuingRestock objects previously created in the Stark Infra API
## Parameters (optional):
-
limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35
-
after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)
-
before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)
-
status [list of strings, default nil]: filter for status of retrieved objects. ex: [“created”, “processing”, “confirmed”]
-
stock_ids [list of string, default nil]: list of stock_ids to filter retrieved objects. ex: [“5656565656565656”, “4545454545454545”]
-
ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [‘5656565656565656’, ‘4545454545454545’]
-
tags [list of strings, default nil]: tags to filter retrieved objects. ex: [“card”, “corporate”]
-
user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call
## Return:
-
generator of IssuingRestocks objects with updated attributes
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/issuing_restock/issuing_restock.rb', line 86 def self.query( limit: nil, after: nil, before: nil, status: nil, stock_ids: nil, ids: nil, tags: nil, user: nil ) after = StarkCore::Utils::Checks.check_date(after) before = StarkCore::Utils::Checks.check_date(before) StarkInfra::Utils::Rest.get_stream( limit: limit, after: after, before: before, status: status, stock_ids: stock_ids, ids: ids, tags: , user: user, **resource ) end |
.resource ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/issuing_restock/issuing_restock.rb', line 144 def self.resource { resource_name: 'IssuingRestock', resource_maker: proc { |json| IssuingRestock.new( count: json['count'], stock_id: json['stock_id'], tags: json['tags'], id: json['id'], status: json['status'], updated: json['updated'], created: json['created'] ) } } end |