Class: Line::Bot::V2::MessagingApi::CouponCreateRequest

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

Overview

Request object for creating a coupon. Contains all configurable coupon properties.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(acquisition_condition:, barcode_image_url: nil, coupon_code: nil, description: nil, end_timestamp:, image_url: nil, max_use_count_per_ticket:, start_timestamp:, title:, usage_condition: nil, reward: nil, visibility:, timezone:, **dynamic_attributes) ⇒ CouponCreateRequest

Returns a new instance of CouponCreateRequest.

Parameters:

  • acquisition_condition (AcquisitionConditionRequest, Hash[Symbol, untyped])
  • 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. Optional.

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

    Detailed description of the coupon. Displayed to users.

  • end_timestamp (Integer)

    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_use_count_per_ticket (Integer)

    Maximum number of times a single coupon ticket can be used. Use -1 to indicate no limit.

  • start_timestamp (Integer)

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

  • title (String)

    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 (CouponRewardRequest, Hash[Symbol, untyped], nil) (defaults to: nil)
  • visibility (String)

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

  • timezone (String)

    (‘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.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/line/bot/v2/messaging_api/model/coupon_create_request.rb', line 69

def initialize(
  acquisition_condition:,
  barcode_image_url: nil,
  coupon_code: nil,
  description: nil,
  end_timestamp:,
  image_url: nil,
  max_use_count_per_ticket:,
  start_timestamp:,
  title:,
  usage_condition: nil,
  reward: nil,
  visibility:,
  timezone:,
  **dynamic_attributes
)
  
  @acquisition_condition = acquisition_condition.is_a?(Line::Bot::V2::MessagingApi::AcquisitionConditionRequest) ? acquisition_condition : Line::Bot::V2::MessagingApi::AcquisitionConditionRequest.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_use_count_per_ticket = max_use_count_per_ticket
  @start_timestamp = start_timestamp
  @title = title
  @usage_condition = usage_condition
  @reward = reward.is_a?(Line::Bot::V2::MessagingApi::CouponRewardRequest) || reward.nil? ? reward : Line::Bot::V2::MessagingApi::CouponRewardRequest.create(**reward) # steep:ignore
  @visibility = visibility
  @timezone = timezone

  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_conditionAcquisitionConditionRequest



18
19
20
# File 'lib/line/bot/v2/messaging_api/model/coupon_create_request.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_create_request.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. Optional.

Returns:

  • (String, nil)

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



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

def coupon_code
  @coupon_code
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_create_request.rb', line 27

def description
  @description
end

#end_timestampInteger

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

Returns:

  • (Integer)

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



30
31
32
# File 'lib/line/bot/v2/messaging_api/model/coupon_create_request.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_create_request.rb', line 33

def image_url
  @image_url
end

#max_use_count_per_ticketInteger

Returns Maximum number of times a single coupon ticket can be used. Use -1 to indicate no limit.

Returns:

  • (Integer)

    Maximum number of times a single coupon ticket can be used. Use -1 to indicate no limit.



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

def max_use_count_per_ticket
  @max_use_count_per_ticket
end

#rewardCouponRewardRequest?

Returns:



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

def reward
  @reward
end

#start_timestampInteger

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

Returns:

  • (Integer)

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



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

def start_timestamp
  @start_timestamp
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)

    (‘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.



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

def timezone
  @timezone
end

#titleString

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

Returns:

  • (String)

    Title of the coupon. Displayed in the coupon list.



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

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.



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

def usage_condition
  @usage_condition
end

#visibilityString

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

Returns:

  • (String)

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



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

def visibility
  @visibility
end

Class Method Details

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

Create an instance of the class from a hash

Parameters:

  • args (Hash)

    Hash containing all the required attributes

Returns:



116
117
118
119
# File 'lib/line/bot/v2/messaging_api/model/coupon_create_request.rb', line 116

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



123
124
125
126
127
128
129
# File 'lib/line/bot/v2/messaging_api/model/coupon_create_request.rb', line 123

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



132
133
134
# File 'lib/line/bot/v2/messaging_api/model/coupon_create_request.rb', line 132

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