Class: Line::Bot::V2::MessagingApi::CouponResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/line/bot/v2/messaging_api/model/coupon_response.rb

Overview

Detailed information about a coupon, including all properties and current status.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(acquisition_condition: nil, barcode_image_url: nil, coupon_code: nil, description: nil, end_timestamp: nil, image_url: nil, max_acquire_count: nil, max_use_count_per_ticket: nil, max_ticket_per_user: nil, start_timestamp: nil, title: nil, usage_condition: nil, reward: nil, visibility: nil, timezone: nil, coupon_id: nil, created_timestamp: nil, status: nil, **dynamic_attributes) ⇒ CouponResponse

Returns a new instance of CouponResponse.

Parameters:

  • acquisition_condition (AcquisitionConditionResponse, Hash[Symbol, untyped], nil) (defaults to: nil)
  • barcode_image_url (String, nil) (defaults to: nil)

    URL of the barcode image associated with the coupon. Used for in-store redemption.

  • coupon_code (String, nil) (defaults to: nil)

    Unique code to be presented by the user to redeem the coupon.

  • description (String, nil) (defaults to: nil)

    Detailed description of the coupon. Displayed to users.

  • end_timestamp (Integer, nil) (defaults to: nil)

    Coupon expiration time (epoch seconds). Coupon cannot be used after this time.

  • image_url (String, nil) (defaults to: nil)

    URL of the main image representing the coupon. Displayed in the coupon list.

  • max_acquire_count (Integer, nil) (defaults to: nil)

    Maximum number of coupons that can be issued in total.

  • max_use_count_per_ticket (Integer, nil) (defaults to: nil)

    Maximum number of times a single coupon ticket can be used.

  • max_ticket_per_user (Integer, nil) (defaults to: nil)

    Maximum number of coupon tickets a single user can acquire.

  • start_timestamp (Integer, nil) (defaults to: nil)

    Coupon start time (epoch seconds). Coupon can be used from this time.

  • title (String, nil) (defaults to: nil)

    Title of the coupon. Displayed in the coupon list.

  • usage_condition (String, nil) (defaults to: nil)

    Conditions for using the coupon. Shown to users.

  • reward (CouponRewardResponse, Hash[Symbol, untyped], nil) (defaults to: nil)
  • visibility (String, nil) (defaults to: nil)

    (‘UNLISTED’|‘PUBLIC’|‘PRIVATE’) Visibility of the coupon. Determines who can see or acquire the coupon.

  • timezone (String, nil) (defaults to: nil)

    (‘ETC_GMT_MINUS_12’|‘ETC_GMT_MINUS_11’|‘PACIFIC_HONOLULU’|‘AMERICA_ANCHORAGE’|‘AMERICA_LOS_ANGELES’|‘AMERICA_PHOENIX’|‘AMERICA_CHICAGO’|‘AMERICA_NEW_YORK’|‘AMERICA_CARACAS’|‘AMERICA_SANTIAGO’|‘AMERICA_ST_JOHNS’|‘AMERICA_SAO_PAULO’|‘ETC_GMT_MINUS_2’|‘ATLANTIC_CAPE_VERDE’|‘EUROPE_LONDON’|‘EUROPE_PARIS’|‘EUROPE_ISTANBUL’|‘EUROPE_MOSCOW’|‘ASIA_TEHRAN’|‘ASIA_TBILISI’|‘ASIA_KABUL’|‘ASIA_TASHKENT’|‘ASIA_COLOMBO’|‘ASIA_KATHMANDU’|‘ASIA_ALMATY’|‘ASIA_RANGOON’|‘ASIA_BANGKOK’|‘ASIA_TAIPEI’|‘ASIA_TOKYO’|‘AUSTRALIA_DARWIN’|‘AUSTRALIA_SYDNEY’|‘ASIA_VLADIVOSTOK’|‘ETC_GMT_PLUS_12’|‘PACIFIC_TONGATAPU’) Timezone for interpreting start and end timestamps.

  • coupon_id (String, nil) (defaults to: nil)

    Unique identifier of the coupon.

  • created_timestamp (Integer, nil) (defaults to: nil)

    Created timestamp (seconds) of the coupon.

  • status (String, nil) (defaults to: nil)

    (‘DRAFT’|‘RUNNING’|‘CLOSED’) Current status of the coupon.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 89

def initialize(
  acquisition_condition: nil,
  barcode_image_url: nil,
  coupon_code: nil,
  description: nil,
  end_timestamp: nil,
  image_url: nil,
  max_acquire_count: nil,
  max_use_count_per_ticket: nil,
  max_ticket_per_user: nil,
  start_timestamp: nil,
  title: nil,
  usage_condition: nil,
  reward: nil,
  visibility: nil,
  timezone: nil,
  coupon_id: nil,
  created_timestamp: nil,
  status: nil,
  **dynamic_attributes
)
  
  @acquisition_condition = acquisition_condition.is_a?(Line::Bot::V2::MessagingApi::AcquisitionConditionResponse) || acquisition_condition.nil? ? acquisition_condition : Line::Bot::V2::MessagingApi::AcquisitionConditionResponse.create(**acquisition_condition) # steep:ignore
  @barcode_image_url = barcode_image_url
  @coupon_code = coupon_code
  @description = description
  @end_timestamp = end_timestamp
  @image_url = image_url
  @max_acquire_count = max_acquire_count
  @max_use_count_per_ticket = max_use_count_per_ticket
  @max_ticket_per_user = max_ticket_per_user
  @start_timestamp = start_timestamp
  @title = title
  @usage_condition = usage_condition
  @reward = reward.is_a?(Line::Bot::V2::MessagingApi::CouponRewardResponse) || reward.nil? ? reward : Line::Bot::V2::MessagingApi::CouponRewardResponse.create(**reward) # steep:ignore
  @visibility = visibility
  @timezone = timezone
  @coupon_id = coupon_id
  @created_timestamp = created_timestamp
  @status = status

  dynamic_attributes.each do |key, value|
    self.class.attr_accessor key

    if value.is_a?(Hash)
      struct_klass = Struct.new(*value.keys.map(&:to_sym))
      struct_values = value.map { |_k, v| v.is_a?(Hash) ? Line::Bot::V2::Utils.hash_to_struct(v) : v }
      instance_variable_set("@#{key}", struct_klass.new(*struct_values))
    else
      instance_variable_set("@#{key}", value)
    end
  end
end

Instance Attribute Details

#acquisition_conditionAcquisitionConditionResponse?



18
19
20
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 18

def acquisition_condition
  @acquisition_condition
end

#barcode_image_urlString?

Returns URL of the barcode image associated with the coupon. Used for in-store redemption.

Returns:

  • (String, nil)

    URL of the barcode image associated with the coupon. Used for in-store redemption.



21
22
23
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 21

def barcode_image_url
  @barcode_image_url
end

#coupon_codeString?

Returns Unique code to be presented by the user to redeem the coupon.

Returns:

  • (String, nil)

    Unique code to be presented by the user to redeem the coupon.



24
25
26
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 24

def coupon_code
  @coupon_code
end

#coupon_idString?

Returns Unique identifier of the coupon.

Returns:

  • (String, nil)

    Unique identifier of the coupon.



63
64
65
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 63

def coupon_id
  @coupon_id
end

#created_timestampInteger?

Returns Created timestamp (seconds) of the coupon.

Returns:

  • (Integer, nil)

    Created timestamp (seconds) of the coupon.



66
67
68
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 66

def created_timestamp
  @created_timestamp
end

#descriptionString?

Returns Detailed description of the coupon. Displayed to users.

Returns:

  • (String, nil)

    Detailed description of the coupon. Displayed to users.



27
28
29
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 27

def description
  @description
end

#end_timestampInteger?

Returns Coupon expiration time (epoch seconds). Coupon cannot be used after this time.

Returns:

  • (Integer, nil)

    Coupon expiration time (epoch seconds). Coupon cannot be used after this time.



30
31
32
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 30

def end_timestamp
  @end_timestamp
end

#image_urlString?

Returns URL of the main image representing the coupon. Displayed in the coupon list.

Returns:

  • (String, nil)

    URL of the main image representing the coupon. Displayed in the coupon list.



33
34
35
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 33

def image_url
  @image_url
end

#max_acquire_countInteger?

Returns Maximum number of coupons that can be issued in total.

Returns:

  • (Integer, nil)

    Maximum number of coupons that can be issued in total.



36
37
38
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 36

def max_acquire_count
  @max_acquire_count
end

#max_ticket_per_userInteger?

Returns Maximum number of coupon tickets a single user can acquire.

Returns:

  • (Integer, nil)

    Maximum number of coupon tickets a single user can acquire.



42
43
44
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 42

def max_ticket_per_user
  @max_ticket_per_user
end

#max_use_count_per_ticketInteger?

Returns Maximum number of times a single coupon ticket can be used.

Returns:

  • (Integer, nil)

    Maximum number of times a single coupon ticket can be used.



39
40
41
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 39

def max_use_count_per_ticket
  @max_use_count_per_ticket
end

#rewardCouponRewardResponse?

Returns:



54
55
56
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 54

def reward
  @reward
end

#start_timestampInteger?

Returns Coupon start time (epoch seconds). Coupon can be used from this time.

Returns:

  • (Integer, nil)

    Coupon start time (epoch seconds). Coupon can be used from this time.



45
46
47
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 45

def start_timestamp
  @start_timestamp
end

#statusString?

Returns (‘DRAFT’|‘RUNNING’|‘CLOSED’) Current status of the coupon.

Returns:

  • (String, nil)

    (‘DRAFT’|‘RUNNING’|‘CLOSED’) Current status of the coupon.



69
70
71
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 69

def status
  @status
end

#timezoneString?

Returns (‘ETC_GMT_MINUS_12’|‘ETC_GMT_MINUS_11’|‘PACIFIC_HONOLULU’|‘AMERICA_ANCHORAGE’|‘AMERICA_LOS_ANGELES’|‘AMERICA_PHOENIX’|‘AMERICA_CHICAGO’|‘AMERICA_NEW_YORK’|‘AMERICA_CARACAS’|‘AMERICA_SANTIAGO’|‘AMERICA_ST_JOHNS’|‘AMERICA_SAO_PAULO’|‘ETC_GMT_MINUS_2’|‘ATLANTIC_CAPE_VERDE’|‘EUROPE_LONDON’|‘EUROPE_PARIS’|‘EUROPE_ISTANBUL’|‘EUROPE_MOSCOW’|‘ASIA_TEHRAN’|‘ASIA_TBILISI’|‘ASIA_KABUL’|‘ASIA_TASHKENT’|‘ASIA_COLOMBO’|‘ASIA_KATHMANDU’|‘ASIA_ALMATY’|‘ASIA_RANGOON’|‘ASIA_BANGKOK’|‘ASIA_TAIPEI’|‘ASIA_TOKYO’|‘AUSTRALIA_DARWIN’|‘AUSTRALIA_SYDNEY’|‘ASIA_VLADIVOSTOK’|‘ETC_GMT_PLUS_12’|‘PACIFIC_TONGATAPU’) Timezone for interpreting start and end timestamps.

Returns:

  • (String, nil)

    (‘ETC_GMT_MINUS_12’|‘ETC_GMT_MINUS_11’|‘PACIFIC_HONOLULU’|‘AMERICA_ANCHORAGE’|‘AMERICA_LOS_ANGELES’|‘AMERICA_PHOENIX’|‘AMERICA_CHICAGO’|‘AMERICA_NEW_YORK’|‘AMERICA_CARACAS’|‘AMERICA_SANTIAGO’|‘AMERICA_ST_JOHNS’|‘AMERICA_SAO_PAULO’|‘ETC_GMT_MINUS_2’|‘ATLANTIC_CAPE_VERDE’|‘EUROPE_LONDON’|‘EUROPE_PARIS’|‘EUROPE_ISTANBUL’|‘EUROPE_MOSCOW’|‘ASIA_TEHRAN’|‘ASIA_TBILISI’|‘ASIA_KABUL’|‘ASIA_TASHKENT’|‘ASIA_COLOMBO’|‘ASIA_KATHMANDU’|‘ASIA_ALMATY’|‘ASIA_RANGOON’|‘ASIA_BANGKOK’|‘ASIA_TAIPEI’|‘ASIA_TOKYO’|‘AUSTRALIA_DARWIN’|‘AUSTRALIA_SYDNEY’|‘ASIA_VLADIVOSTOK’|‘ETC_GMT_PLUS_12’|‘PACIFIC_TONGATAPU’) Timezone for interpreting start and end timestamps.



60
61
62
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 60

def timezone
  @timezone
end

#titleString?

Returns Title of the coupon. Displayed in the coupon list.

Returns:

  • (String, nil)

    Title of the coupon. Displayed in the coupon list.



48
49
50
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 48

def title
  @title
end

#usage_conditionString?

Returns Conditions for using the coupon. Shown to users.

Returns:

  • (String, nil)

    Conditions for using the coupon. Shown to users.



51
52
53
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 51

def usage_condition
  @usage_condition
end

#visibilityString?

Returns (‘UNLISTED’|‘PUBLIC’|‘PRIVATE’) Visibility of the coupon. Determines who can see or acquire the coupon.

Returns:

  • (String, nil)

    (‘UNLISTED’|‘PUBLIC’|‘PRIVATE’) Visibility of the coupon. Determines who can see or acquire the coupon.



57
58
59
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 57

def visibility
  @visibility
end

Class Method Details

.create(args) ⇒ Line::Bot::V2::MessagingApi::CouponResponse

Create an instance of the class from a hash

Parameters:

  • args (Hash)

    Hash containing all the required attributes

Returns:



146
147
148
149
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 146

def self.create(args) # steep:ignore
  symbolized_args = Line::Bot::V2::Utils.deep_symbolize(args)
  return new(**symbolized_args) # steep:ignore
end

Instance Method Details

#==(other) ⇒ Boolean

Returns true if the objects are equal, false otherwise.

Parameters:

  • other (Object)

    Object to compare

Returns:

  • (Boolean)

    true if the objects are equal, false otherwise



153
154
155
156
157
158
159
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 153

def ==(other)
  return false unless self.class == other.class

  instance_variables.all? do |var|
      instance_variable_get(var) == other.instance_variable_get(var)
  end
end

#hashInteger

Returns Hash code of the object.

Returns:

  • (Integer)

    Hash code of the object



162
163
164
# File 'lib/line/bot/v2/messaging_api/model/coupon_response.rb', line 162

def hash
  [self.class, *instance_variables.map { |var| instance_variable_get(var) }].hash
end