Class: UspsApi::CampaignEdit

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/campaign_edit.rb

Overview

CampaignEdit 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(campaign_type: SKIP, mailpiece_shape: SKIP, mid: SKIP, mail_owner_crid: SKIP, mail_owner_name: SKIP, campaign_code: SKIP, campaign_title: SKIP, brand_display_name: SKIP, start_date: SKIP, end_date: SKIP, start_serial: SKIP, end_serial: SKIP, target_url: SKIP, ride_along: SKIP, replacement_image: SKIP, is_shareable: SKIP, has_url_params: SKIP, additional_properties: nil) ⇒ CampaignEdit

Returns a new instance of CampaignEdit.



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/usps_api/models/campaign_edit.rb', line 163

def initialize(campaign_type: SKIP, mailpiece_shape: SKIP, mid: SKIP,
               mail_owner_crid: SKIP, mail_owner_name: SKIP,
               campaign_code: SKIP, campaign_title: SKIP,
               brand_display_name: SKIP, start_date: SKIP, end_date: SKIP,
               start_serial: SKIP, end_serial: SKIP, target_url: SKIP,
               ride_along: SKIP, replacement_image: SKIP,
               is_shareable: SKIP, has_url_params: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @campaign_type = campaign_type unless campaign_type == SKIP
  @mailpiece_shape = mailpiece_shape unless mailpiece_shape == SKIP
  @mid = mid unless mid == SKIP
  @mail_owner_crid = mail_owner_crid unless mail_owner_crid == SKIP
  @mail_owner_name = mail_owner_name unless mail_owner_name == SKIP
  @campaign_code = campaign_code unless campaign_code == SKIP
  @campaign_title = campaign_title unless campaign_title == SKIP
  @brand_display_name = brand_display_name unless brand_display_name == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP
  @start_serial = start_serial unless start_serial == SKIP
  @end_serial = end_serial unless end_serial == SKIP
  @target_url = target_url unless target_url == SKIP
  @ride_along = ride_along unless ride_along == SKIP
  @replacement_image = replacement_image unless replacement_image == SKIP
  @is_shareable = is_shareable unless is_shareable == SKIP
  @has_url_params = has_url_params unless has_url_params == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#brand_display_nameString

User defined field that is placed on Informed Delivery’s UIs when campaign is displayed.

Returns:

  • (String)


56
57
58
# File 'lib/usps_api/models/campaign_edit.rb', line 56

def brand_display_name
  @brand_display_name
end

#campaign_codeString

User defined field that describes the campaign being created. This field is put into the campaign reports created for the campaign.

Returns:

  • (String)


46
47
48
# File 'lib/usps_api/models/campaign_edit.rb', line 46

def campaign_code
  @campaign_code
end

#campaign_titleString

User defined field that describes the campaign being created. This field is put into the campaign reports created for the campaign.

Returns:

  • (String)


51
52
53
# File 'lib/usps_api/models/campaign_edit.rb', line 51

def campaign_title
  @campaign_title
end

#campaign_typeString

Identifier on what types of mail pieces the campaign should be applied to

* LETTER
* CARD
* FLAT
* PACKAGE

Returns:

  • (String)


18
19
20
# File 'lib/usps_api/models/campaign_edit.rb', line 18

def campaign_type
  @campaign_type
end

#end_dateDate

Last day campaign will be displayed

Returns:

  • (Date)


64
65
66
# File 'lib/usps_api/models/campaign_edit.rb', line 64

def end_date
  @end_date
end

#end_serialString

The upper limit of the serial range for SEQ type campaigns. This field is required for SEQ campaigns only and is not allowed for submission for any other campaign types.

Returns:

  • (String)


76
77
78
# File 'lib/usps_api/models/campaign_edit.rb', line 76

def end_serial
  @end_serial
end

#has_url_paramsTrueClass | FalseClass

An indicator dictating whether a campaign is eligible for MID and Serial Number parameters to be appended to the end of the Target URL for tracking purposes. By default, the MID and Serial Number parameters for a given mailpiece will be added to end of the Target URL that users are taken to upon clicking on a campaign. If a mailer opts out of this feature, then these MID and Serial Number fields will not be appended to the campaign’s Target URL.

Returns:

  • (TrueClass | FalseClass)


110
111
112
# File 'lib/usps_api/models/campaign_edit.rb', line 110

def has_url_params
  @has_url_params
end

#is_shareableTrueClass | FalseClass

An indicator dictating whether a campaign is eligible for Social Sharing. By default, mail campaigns will be displayed alongside options to share the campaign to various social media platforms. If a mailer opts out of this feature, then these options will not be displayed with the campaign.

Returns:

  • (TrueClass | FalseClass)


100
101
102
# File 'lib/usps_api/models/campaign_edit.rb', line 100

def is_shareable
  @is_shareable
end

#mail_owner_cridString

Customer Registration ID (CRID) of the Mail Owner associated with the Informed Delivery campaign.

Returns:

  • (String)


37
38
39
# File 'lib/usps_api/models/campaign_edit.rb', line 37

def mail_owner_crid
  @mail_owner_crid
end

#mail_owner_nameString

Name of the Mail Owner associated with the Informed Delivery campaign.

Returns:

  • (String)


41
42
43
# File 'lib/usps_api/models/campaign_edit.rb', line 41

def mail_owner_name
  @mail_owner_name
end

#mailpiece_shapeString

Identifier on what types of mail pieces the campaign should be applied to

* LT (Letter)
* CD (Card)
* FL (Flat)

Returns:

  • (String)


25
26
27
# File 'lib/usps_api/models/campaign_edit.rb', line 25

def mailpiece_shape
  @mailpiece_shape
end

#midString

The Mailer ID for the campaign - this field will be used to match IMBs to MID and SEQ type campaigns. If an IMB has the Mailer ID (MID) associated with an active MID/SEQ campaign, it is eligible to be displayed with the campaign’s image and Target URL.

Returns:

  • (String)


32
33
34
# File 'lib/usps_api/models/campaign_edit.rb', line 32

def mid
  @mid
end

#replacement_imageString

The image that is displayed instead of the mailpiece image for mailpieces matched with a mail campaign. This field is required if the Campaign Shape Type is ‘FL’, otherwise this field is optional.

Returns:

  • (String)


93
94
95
# File 'lib/usps_api/models/campaign_edit.rb', line 93

def replacement_image
  @replacement_image
end

#ride_alongString

The image that is displayed below the replacement or mailpiece image for mailpieces matched with a mail campaign. When clicked, this image will take users to the Target URL of the campaign. This field is required.

Returns:

  • (String)


87
88
89
# File 'lib/usps_api/models/campaign_edit.rb', line 87

def ride_along
  @ride_along
end

#start_dateDate

First day campaign will be displayed

Returns:

  • (Date)


60
61
62
# File 'lib/usps_api/models/campaign_edit.rb', line 60

def start_date
  @start_date
end

#start_serialString

The lower limit of the serial range for SEQ type campaigns. This field is required for SEQ campaigns only and is not allowed for submission for any other campaign types.

Returns:

  • (String)


70
71
72
# File 'lib/usps_api/models/campaign_edit.rb', line 70

def start_serial
  @start_serial
end

#target_urlString

The URL that users are redirected to when clicking on the Ridealong image or Learn More link for a campaign. This field is required.

Returns:

  • (String)


81
82
83
# File 'lib/usps_api/models/campaign_edit.rb', line 81

def target_url
  @target_url
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/usps_api/models/campaign_edit.rb', line 195

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  campaign_type = hash.key?('campaignType') ? hash['campaignType'] : SKIP
  mailpiece_shape =
    hash.key?('mailpieceShape') ? hash['mailpieceShape'] : SKIP
  mid = hash.key?('MID') ? hash['MID'] : SKIP
  mail_owner_crid =
    hash.key?('mailOwnerCRID') ? hash['mailOwnerCRID'] : SKIP
  mail_owner_name =
    hash.key?('mailOwnerName') ? hash['mailOwnerName'] : SKIP
  campaign_code = hash.key?('campaignCode') ? hash['campaignCode'] : SKIP
  campaign_title = hash.key?('campaignTitle') ? hash['campaignTitle'] : SKIP
  brand_display_name =
    hash.key?('brandDisplayName') ? hash['brandDisplayName'] : SKIP
  start_date = hash.key?('startDate') ? hash['startDate'] : SKIP
  end_date = hash.key?('endDate') ? hash['endDate'] : SKIP
  start_serial = hash.key?('startSerial') ? hash['startSerial'] : SKIP
  end_serial = hash.key?('endSerial') ? hash['endSerial'] : SKIP
  target_url = hash.key?('targetUrl') ? hash['targetUrl'] : SKIP
  ride_along = hash.key?('rideAlong') ? hash['rideAlong'] : SKIP
  replacement_image =
    hash.key?('replacementImage') ? hash['replacementImage'] : SKIP
  is_shareable = hash.key?('isShareable') ? hash['isShareable'] : SKIP
  has_url_params = hash.key?('hasUrlParams') ? hash['hasUrlParams'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  CampaignEdit.new(campaign_type: campaign_type,
                   mailpiece_shape: mailpiece_shape,
                   mid: mid,
                   mail_owner_crid: mail_owner_crid,
                   mail_owner_name: mail_owner_name,
                   campaign_code: campaign_code,
                   campaign_title: campaign_title,
                   brand_display_name: brand_display_name,
                   start_date: start_date,
                   end_date: end_date,
                   start_serial: start_serial,
                   end_serial: end_serial,
                   target_url: target_url,
                   ride_along: ride_along,
                   replacement_image: replacement_image,
                   is_shareable: is_shareable,
                   has_url_params: has_url_params,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/usps_api/models/campaign_edit.rb', line 113

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['campaign_type'] = 'campaignType'
  @_hash['mailpiece_shape'] = 'mailpieceShape'
  @_hash['mid'] = 'MID'
  @_hash['mail_owner_crid'] = 'mailOwnerCRID'
  @_hash['mail_owner_name'] = 'mailOwnerName'
  @_hash['campaign_code'] = 'campaignCode'
  @_hash['campaign_title'] = 'campaignTitle'
  @_hash['brand_display_name'] = 'brandDisplayName'
  @_hash['start_date'] = 'startDate'
  @_hash['end_date'] = 'endDate'
  @_hash['start_serial'] = 'startSerial'
  @_hash['end_serial'] = 'endSerial'
  @_hash['target_url'] = 'targetUrl'
  @_hash['ride_along'] = 'rideAlong'
  @_hash['replacement_image'] = 'replacementImage'
  @_hash['is_shareable'] = 'isShareable'
  @_hash['has_url_params'] = 'hasUrlParams'
  @_hash
end

.nullablesObject

An array for nullable fields



159
160
161
# File 'lib/usps_api/models/campaign_edit.rb', line 159

def self.nullables
  []
end

.optionalsObject

An array for optional fields



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/usps_api/models/campaign_edit.rb', line 136

def self.optionals
  %w[
    campaign_type
    mailpiece_shape
    mid
    mail_owner_crid
    mail_owner_name
    campaign_code
    campaign_title
    brand_display_name
    start_date
    end_date
    start_serial
    end_serial
    target_url
    ride_along
    replacement_image
    is_shareable
    has_url_params
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/usps_api/models/campaign_edit.rb', line 263

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} campaign_type: #{@campaign_type.inspect}, mailpiece_shape:"\
  " #{@mailpiece_shape.inspect}, mid: #{@mid.inspect}, mail_owner_crid:"\
  " #{@mail_owner_crid.inspect}, mail_owner_name: #{@mail_owner_name.inspect}, campaign_code:"\
  " #{@campaign_code.inspect}, campaign_title: #{@campaign_title.inspect}, brand_display_name:"\
  " #{@brand_display_name.inspect}, start_date: #{@start_date.inspect}, end_date:"\
  " #{@end_date.inspect}, start_serial: #{@start_serial.inspect}, end_serial:"\
  " #{@end_serial.inspect}, target_url: #{@target_url.inspect}, ride_along:"\
  " #{@ride_along.inspect}, replacement_image: #{@replacement_image.inspect}, is_shareable:"\
  " #{@is_shareable.inspect}, has_url_params: #{@has_url_params.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



251
252
253
254
255
256
257
258
259
260
# File 'lib/usps_api/models/campaign_edit.rb', line 251

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} campaign_type: #{@campaign_type}, mailpiece_shape: #{@mailpiece_shape},"\
  " mid: #{@mid}, mail_owner_crid: #{@mail_owner_crid}, mail_owner_name: #{@mail_owner_name},"\
  " campaign_code: #{@campaign_code}, campaign_title: #{@campaign_title}, brand_display_name:"\
  " #{@brand_display_name}, start_date: #{@start_date}, end_date: #{@end_date}, start_serial:"\
  " #{@start_serial}, end_serial: #{@end_serial}, target_url: #{@target_url}, ride_along:"\
  " #{@ride_along}, replacement_image: #{@replacement_image}, is_shareable: #{@is_shareable},"\
  " has_url_params: #{@has_url_params}, additional_properties: #{@additional_properties}>"
end