Class: ApiReference::CouponQueryParams

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/coupon_query_params.rb

Overview

CouponQueryParams Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(limit: 20, cursor: SKIP, show_archived: SKIP, redemption_code: SKIP) ⇒ CouponQueryParams

Returns a new instance of CouponQueryParams.



59
60
61
62
63
64
65
# File 'lib/api_reference/models/coupon_query_params.rb', line 59

def initialize(limit: 20, cursor: SKIP, show_archived: SKIP,
               redemption_code: SKIP)
  @limit = limit unless limit == SKIP
  @cursor = cursor unless cursor == SKIP
  @show_archived = show_archived unless show_archived == SKIP
  @redemption_code = redemption_code unless redemption_code == SKIP
end

Instance Attribute Details

#cursorString

Cursor for pagination. This can be populated by the next_cursor value returned from the initial request.

Returns:

  • (String)


19
20
21
# File 'lib/api_reference/models/coupon_query_params.rb', line 19

def cursor
  @cursor
end

#limitInteger

The number of items to fetch. Defaults to 20.

Returns:

  • (Integer)


14
15
16
# File 'lib/api_reference/models/coupon_query_params.rb', line 14

def limit
  @limit
end

#redemption_codeString

Filter to coupons matching this redemption code.

Returns:

  • (String)


28
29
30
# File 'lib/api_reference/models/coupon_query_params.rb', line 28

def redemption_code
  @redemption_code
end

#show_archivedTrueClass | FalseClass

Show archived coupons as well (by default, this endpoint only returns active coupons).

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/api_reference/models/coupon_query_params.rb', line 24

def show_archived
  @show_archived
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/api_reference/models/coupon_query_params.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  limit = hash['limit'] ||= 20
  cursor = hash.key?('cursor') ? hash['cursor'] : SKIP
  show_archived = hash.key?('show_archived') ? hash['show_archived'] : SKIP
  redemption_code =
    hash.key?('redemption_code') ? hash['redemption_code'] : SKIP

  # Create object from extracted values.
  CouponQueryParams.new(limit: limit,
                        cursor: cursor,
                        show_archived: show_archived,
                        redemption_code: redemption_code)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
38
# File 'lib/api_reference/models/coupon_query_params.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['limit'] = 'limit'
  @_hash['cursor'] = 'cursor'
  @_hash['show_archived'] = 'show_archived'
  @_hash['redemption_code'] = 'redemption_code'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
54
55
56
57
# File 'lib/api_reference/models/coupon_query_params.rb', line 51

def self.nullables
  %w[
    cursor
    show_archived
    redemption_code
  ]
end

.optionalsObject

An array for optional fields



41
42
43
44
45
46
47
48
# File 'lib/api_reference/models/coupon_query_params.rb', line 41

def self.optionals
  %w[
    limit
    cursor
    show_archived
    redemption_code
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



93
94
95
96
97
# File 'lib/api_reference/models/coupon_query_params.rb', line 93

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} limit: #{@limit.inspect}, cursor: #{@cursor.inspect}, show_archived:"\
  " #{@show_archived.inspect}, redemption_code: #{@redemption_code.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



86
87
88
89
90
# File 'lib/api_reference/models/coupon_query_params.rb', line 86

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} limit: #{@limit}, cursor: #{@cursor}, show_archived: #{@show_archived},"\
  " redemption_code: #{@redemption_code}>"
end