Class: Magentwo::Coupon
- Inherits:
-
Base
- Object
- Base
- Magentwo::Coupon
show all
- Defined in:
- lib/model/coupon.rb
Constant Summary
collapse
- Attributes =
%i(coupon_id rule_id code usage_per_customer times_used is_primary type)
Constants inherited
from Base
Base::DatasetMethods
Class Method Summary
collapse
Methods inherited from Base
[], all, base_path, call, #call, #check_presence, dataset, #delete, each, each_page, first, get, #initialize, lower_case_name, map, #save, #to_h, #to_json, #validate
Constructor Details
This class inherits a constructor from Magentwo::Base
Class Method Details
.generate(rule_id, quantity: 1, length: 16, format: (:alpha), delimiter: "-", delimiter_at_every: 4) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/model/coupon.rb', line 11
def generate rule_id, quantity:1, length:16, format:(:alpha), delimiter:"-", delimiter_at_every:4
format = format.to_sym
Magentwo::Validator.one_of format, :num, :alpha, :alphanum
self.call :post, "#{base_path}/generate",
{
:couponSpec => {
:rule_id => rule_id,
:quantity => quantity,
:length => length,
:format => format,
:delimiter => delimiter,
:delimiter_at_every => delimiter_at_every
}
}
end
|
.get_path ⇒ Object
7
8
9
|
# File 'lib/model/coupon.rb', line 7
def get_path
"#{base_path}/search"
end
|
.unique_identifier ⇒ Object
27
28
29
|
# File 'lib/model/coupon.rb', line 27
def unique_identifier
:coupon_id
end
|