Class: AdvancedBilling::ListCouponsFilter
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::ListCouponsFilter
- Defined in:
- lib/advanced_billing/models/list_coupons_filter.rb
Overview
ListCouponsFilter Model.
Instance Attribute Summary collapse
-
#codes ⇒ Array[String]
Allows fetching coupons with matching codes based on provided values.
-
#date_field ⇒ BasicDateField
The type of filter you would like to apply to your search.
-
#end_date ⇒ Date
The end date (format YYYY-MM-DD) with which to filter the date_field.
-
#end_datetime ⇒ DateTime
The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field.
-
#ids ⇒ Array[Integer]
Allows fetching coupons with matching id based on provided values.
-
#start_date ⇒ Date
The start date (format YYYY-MM-DD) with which to filter the date_field.
-
#start_datetime ⇒ DateTime
The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field.
-
#use_site_exchange_rate ⇒ TrueClass | FalseClass
Allows fetching coupons with matching use_site_exchange_rate based on provided value.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(date_field: SKIP, start_date: SKIP, end_date: SKIP, start_datetime: SKIP, end_datetime: SKIP, ids: SKIP, codes: SKIP, use_site_exchange_rate: SKIP, additional_properties: {}) ⇒ ListCouponsFilter
constructor
A new instance of ListCouponsFilter.
- #to_custom_end_datetime ⇒ Object
- #to_custom_start_datetime ⇒ Object
Methods inherited from BaseModel
Constructor Details
#initialize(date_field: SKIP, start_date: SKIP, end_date: SKIP, start_datetime: SKIP, end_datetime: SKIP, ids: SKIP, codes: SKIP, use_site_exchange_rate: SKIP, additional_properties: {}) ⇒ ListCouponsFilter
Returns a new instance of ListCouponsFilter.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 98 def initialize(date_field: SKIP, start_date: SKIP, end_date: SKIP, start_datetime: SKIP, end_datetime: SKIP, ids: SKIP, codes: SKIP, use_site_exchange_rate: SKIP, additional_properties: {}) @date_field = date_field unless date_field == SKIP @start_date = start_date unless start_date == SKIP @end_date = end_date unless end_date == SKIP @start_datetime = start_datetime unless start_datetime == SKIP @end_datetime = end_datetime unless end_datetime == SKIP @ids = ids unless ids == SKIP @codes = codes unless codes == SKIP @use_site_exchange_rate = use_site_exchange_rate unless use_site_exchange_rate == SKIP # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#codes ⇒ Array[String]
Allows fetching coupons with matching codes based on provided values. Use in query ‘filter=free,free_trial`.
58 59 60 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 58 def codes @codes end |
#date_field ⇒ BasicDateField
The type of filter you would like to apply to your search. Use in query ‘filter=created_at`.
16 17 18 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 16 def date_field @date_field end |
#end_date ⇒ Date
The end date (format YYYY-MM-DD) with which to filter the date_field. Returns coupons with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. Use in query ‘filter=2011-12-15`.
30 31 32 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 30 def end_date @end_date end |
#end_datetime ⇒ DateTime
The end date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns coupons with a timestamp at or before exact time provided in query. You can specify timezone in query - otherwise your site’s time zone will be used. If provided, this parameter will be used instead of end_date. Use in query ‘filter=2011-12-1T10:15:30+01:00`.
48 49 50 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 48 def end_datetime @end_datetime end |
#ids ⇒ Array[Integer]
Allows fetching coupons with matching id based on provided values. Use in query ‘filter=1,2,3`.
53 54 55 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 53 def ids @ids end |
#start_date ⇒ Date
The start date (format YYYY-MM-DD) with which to filter the date_field. Returns coupons with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. Use in query ‘filter=2011-12-17`.
23 24 25 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 23 def start_date @start_date end |
#start_datetime ⇒ DateTime
The start date and time (format YYYY-MM-DD HH:MM:SS) with which to filter the date_field. Returns coupons with a timestamp at or after exact time provided in query. You can specify timezone in query - otherwise your site’s time zone will be used. If provided, this parameter will be used instead of start_date. Use in query ‘filter=2011-12-19T10:15:30+01:00`.
39 40 41 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 39 def start_datetime @start_datetime end |
#use_site_exchange_rate ⇒ TrueClass | FalseClass
Allows fetching coupons with matching use_site_exchange_rate based on provided value. Use in query ‘filter=true`.
63 64 65 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 63 def use_site_exchange_rate @use_site_exchange_rate end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 118 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. date_field = hash.key?('date_field') ? hash['date_field'] : SKIP start_date = hash.key?('start_date') ? hash['start_date'] : SKIP end_date = hash.key?('end_date') ? hash['end_date'] : SKIP start_datetime = if hash.key?('start_datetime') (DateTimeHelper.from_rfc3339(hash['start_datetime']) if hash['start_datetime']) else SKIP end end_datetime = if hash.key?('end_datetime') (DateTimeHelper.from_rfc3339(hash['end_datetime']) if hash['end_datetime']) else SKIP end ids = hash.key?('ids') ? hash['ids'] : SKIP codes = hash.key?('codes') ? hash['codes'] : SKIP use_site_exchange_rate = hash.key?('use_site_exchange_rate') ? hash['use_site_exchange_rate'] : SKIP # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. ListCouponsFilter.new(date_field: date_field, start_date: start_date, end_date: end_date, start_datetime: start_datetime, end_datetime: end_datetime, ids: ids, codes: codes, use_site_exchange_rate: use_site_exchange_rate, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 66 def self.names @_hash = {} if @_hash.nil? @_hash['date_field'] = 'date_field' @_hash['start_date'] = 'start_date' @_hash['end_date'] = 'end_date' @_hash['start_datetime'] = 'start_datetime' @_hash['end_datetime'] = 'end_datetime' @_hash['ids'] = 'ids' @_hash['codes'] = 'codes' @_hash['use_site_exchange_rate'] = 'use_site_exchange_rate' @_hash end |
.nullables ⇒ Object
An array for nullable fields
94 95 96 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 94 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 80 def self.optionals %w[ date_field start_date end_date start_datetime end_datetime ids codes use_site_exchange_rate ] end |
Instance Method Details
#to_custom_end_datetime ⇒ Object
159 160 161 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 159 def to_custom_end_datetime DateTimeHelper.to_rfc3339(end_datetime) end |
#to_custom_start_datetime ⇒ Object
155 156 157 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 155 def to_custom_start_datetime DateTimeHelper.to_rfc3339(start_datetime) end |