Class: ShopifyAPI::DiscountCode
- Inherits:
-
Rest::Base
- Object
- Rest::Base
- ShopifyAPI::DiscountCode
- Extended by:
- T::Sig
- Defined in:
- lib/shopify_api/rest/resources/2022_04/discount_code.rb,
lib/shopify_api/rest/resources/2022_07/discount_code.rb,
lib/shopify_api/rest/resources/2022_10/discount_code.rb,
lib/shopify_api/rest/resources/2023_01/discount_code.rb,
lib/shopify_api/rest/resources/2023_04/discount_code.rb,
lib/shopify_api/rest/resources/2023_07/discount_code.rb,
lib/shopify_api/rest/resources/2023_10/discount_code.rb,
lib/shopify_api/rest/resources/2024_01/discount_code.rb,
lib/shopify_api/rest/resources/2024_04/discount_code.rb,
lib/shopify_api/rest/resources/2024_07/discount_code.rb,
lib/shopify_api/rest/resources/2024_10/discount_code.rb
Instance Attribute Summary collapse
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#price_rule_id ⇒ Object
readonly
Returns the value of attribute price_rule_id.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#usage_count ⇒ Object
readonly
Returns the value of attribute usage_count.
Attributes inherited from Rest::Base
Class Method Summary collapse
- .all(price_rule_id: nil, batch_id: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
- .count(times_used: nil, times_used_min: nil, times_used_max: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
- .delete(id:, price_rule_id: nil, session: ShopifyAPI::Context.active_session) ⇒ Object
- .find(id:, price_rule_id: nil, session: ShopifyAPI::Context.active_session) ⇒ Object
- .get_all(price_rule_id: nil, batch_id: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
- .lookup(code: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
Instance Method Summary collapse
- #batch(body: nil, **kwargs) ⇒ Object
-
#initialize(session: ShopifyAPI::Context.active_session, from_hash: nil) ⇒ DiscountCode
constructor
A new instance of DiscountCode.
Methods inherited from Rest::Base
api_call_limit, base_find, class_name, create_instance, create_instances_from_response, #delete, get_path, get_path_ids, has_many?, has_one?, inherited, json_body_name, json_response_body_names, #method_missing, next_page?, next_page_info, prev_page?, prev_page_info, primary_key, read_only_attributes, request, #respond_to_missing?, retry_request_after, #save, #save!, #to_hash
Constructor Details
#initialize(session: ShopifyAPI::Context.active_session, from_hash: nil) ⇒ DiscountCode
Returns a new instance of DiscountCode.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 19 def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil) @code = T.let(nil, T.nilable(String)) @created_at = T.let(nil, T.nilable(String)) @errors = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped])) @id = T.let(nil, T.nilable(Integer)) @price_rule_id = T.let(nil, T.nilable(Integer)) @updated_at = T.let(nil, T.nilable(String)) @usage_count = T.let(nil, T.nilable(Integer)) super(session: session, from_hash: from_hash) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ShopifyAPI::Rest::Base
Instance Attribute Details
#code ⇒ Object (readonly)
Returns the value of attribute code.
48 49 50 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 48 def code @code end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
50 51 52 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 50 def created_at @created_at end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
52 53 54 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 52 def errors @errors end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
54 55 56 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 54 def id @id end |
#price_rule_id ⇒ Object (readonly)
Returns the value of attribute price_rule_id.
56 57 58 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 56 def price_rule_id @price_rule_id end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
58 59 60 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 58 def updated_at @updated_at end |
#usage_count ⇒ Object (readonly)
Returns the value of attribute usage_count.
60 61 62 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 60 def usage_count @usage_count end |
Class Method Details
.all(price_rule_id: nil, batch_id: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 112 def all( price_rule_id: nil, batch_id: nil, session: ShopifyAPI::Context.active_session, **kwargs ) response = base_find( session: session, ids: {price_rule_id: price_rule_id, batch_id: batch_id}, params: {}.merge(kwargs).compact, ) T.cast(response, T::Array[DiscountCode]) end |
.count(times_used: nil, times_used_min: nil, times_used_max: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 136 def count( times_used: nil, times_used_min: nil, times_used_max: nil, session: ShopifyAPI::Context.active_session, **kwargs ) request( http_method: :get, operation: :count, session: session, ids: {}, params: {times_used: times_used, times_used_min: times_used_min, times_used_max: times_used_max}.merge(kwargs).compact, body: {}, entity: nil, ) end |
.delete(id:, price_rule_id: nil, session: ShopifyAPI::Context.active_session) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 90 def delete( id:, price_rule_id: nil, session: ShopifyAPI::Context.active_session ) request( http_method: :delete, operation: :delete, session: session, ids: {id: id, price_rule_id: price_rule_id}, params: {}, ) end |
.find(id:, price_rule_id: nil, session: ShopifyAPI::Context.active_session) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 70 def find( id:, price_rule_id: nil, session: ShopifyAPI::Context.active_session ) result = base_find( session: session, ids: {id: id, price_rule_id: price_rule_id}, params: {}, ) T.cast(result[0], T.nilable(DiscountCode)) end |
.get_all(price_rule_id: nil, batch_id: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 162 def get_all( price_rule_id: nil, batch_id: nil, session: ShopifyAPI::Context.active_session, **kwargs ) request( http_method: :get, operation: :get_all, session: session, ids: {price_rule_id: price_rule_id, batch_id: batch_id}, params: {}.merge(kwargs).compact, body: {}, entity: nil, ) end |
.lookup(code: nil, session: ShopifyAPI::Context.active_session, **kwargs) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 186 def lookup( code: nil, session: ShopifyAPI::Context.active_session, **kwargs ) request( http_method: :get, operation: :lookup, session: session, ids: {}, params: {code: code}.merge(kwargs).compact, body: {}, entity: nil, ) end |
Instance Method Details
#batch(body: nil, **kwargs) ⇒ Object
210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'lib/shopify_api/rest/resources/2022_04/discount_code.rb', line 210 def batch( body: nil, **kwargs ) self.class.request( http_method: :post, operation: :batch, session: @session, ids: {price_rule_id: @price_rule_id}, params: {}.merge(kwargs).compact, body: body, entity: self, ) end |