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.
-
#include_archived ⇒ TrueClass | FalseClass
Controls returning archived coupons.
-
#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
If true, restricts the list to coupons whose pricing is recalculated from the site’s current exchange rates, so their currency_prices array contains on-the-fly conversions rather than stored price records.
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, include_archived: SKIP, additional_properties: {}) ⇒ ListCouponsFilter
constructor
A new instance of ListCouponsFilter.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_end_datetime ⇒ Object
- #to_custom_start_datetime ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #get_additional_properties, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
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, include_archived: SKIP, additional_properties: {}) ⇒ ListCouponsFilter
Returns a new instance of ListCouponsFilter.
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 109 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, include_archived: SKIP, additional_properties: {}) # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end @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 @include_archived = include_archived unless include_archived == SKIP 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 |
#include_archived ⇒ TrueClass | FalseClass
Controls returning archived coupons.
72 73 74 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 72 def include_archived @include_archived 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
If true, restricts the list to coupons whose pricing is recalculated from the site’s current exchange rates, so their currency_prices array contains on-the-fly conversions rather than stored price records. If false, restricts the list to coupons that have manually defined amounts for each currency, ensuring the response includes the saved currency_prices entries instead of exchange-rate-derived values. Use in query ‘filter=true`.
68 69 70 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 68 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.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 130 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 include_archived = hash.key?('include_archived') ? hash['include_archived'] : SKIP # Clean out expected properties from Hash. additional_properties = hash.reject { |k, _| names.value?(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, include_archived: include_archived, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 75 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['include_archived'] = 'include_archived' @_hash end |
.nullables ⇒ Object
An array for nullable fields
105 106 107 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 105 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 90 def self.optionals %w[ date_field start_date end_date start_datetime end_datetime ids codes use_site_exchange_rate include_archived ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
189 190 191 192 193 194 195 196 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 189 def inspect class_name = self.class.name.split('::').last "<#{class_name} date_field: #{@date_field.inspect}, start_date: #{@start_date.inspect},"\ " end_date: #{@end_date.inspect}, start_datetime: #{@start_datetime.inspect}, end_datetime:"\ " #{@end_datetime.inspect}, ids: #{@ids.inspect}, codes: #{@codes.inspect},"\ " use_site_exchange_rate: #{@use_site_exchange_rate.inspect}, include_archived:"\ " #{@include_archived.inspect}, additional_properties: #{get_additional_properties}>" end |
#to_custom_end_datetime ⇒ Object
174 175 176 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 174 def to_custom_end_datetime DateTimeHelper.to_rfc3339(end_datetime) end |
#to_custom_start_datetime ⇒ Object
170 171 172 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 170 def to_custom_start_datetime DateTimeHelper.to_rfc3339(start_datetime) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
179 180 181 182 183 184 185 186 |
# File 'lib/advanced_billing/models/list_coupons_filter.rb', line 179 def to_s class_name = self.class.name.split('::').last "<#{class_name} 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},"\ " include_archived: #{@include_archived}, additional_properties:"\ " #{get_additional_properties}>" end |