Class: UspsApi::EditPackageCampaign

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

Overview

EditPackageCampaign 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(mid: SKIP, mail_owner_crid: SKIP, mail_owner_name: SKIP, campaign_code: SKIP, campaign_grouping_code: SKIP, campaign_title: SKIP, brand_display_name: SKIP, start_date: SKIP, end_date: SKIP, target_url: SKIP, ride_along: SKIP, additional_properties: nil) ⇒ EditPackageCampaign

Returns a new instance of EditPackageCampaign.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# File 'lib/usps_api/models/edit_package_campaign.rb', line 103

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

  @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_grouping_code = campaign_grouping_code unless campaign_grouping_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
  @target_url = target_url unless target_url == SKIP
  @ride_along = ride_along unless ride_along == 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)


43
44
45
# File 'lib/usps_api/models/edit_package_campaign.rb', line 43

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)


28
29
30
# File 'lib/usps_api/models/edit_package_campaign.rb', line 28

def campaign_code
  @campaign_code
end

#campaign_grouping_codeString

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

Returns:

  • (String)


33
34
35
# File 'lib/usps_api/models/edit_package_campaign.rb', line 33

def campaign_grouping_code
  @campaign_grouping_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)


38
39
40
# File 'lib/usps_api/models/edit_package_campaign.rb', line 38

def campaign_title
  @campaign_title
end

#end_dateDate

Last day campaign will be displayed

Returns:

  • (Date)


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

def end_date
  @end_date
end

#mail_owner_cridString

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

Returns:

  • (String)


19
20
21
# File 'lib/usps_api/models/edit_package_campaign.rb', line 19

def mail_owner_crid
  @mail_owner_crid
end

#mail_owner_nameString

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

Returns:

  • (String)


23
24
25
# File 'lib/usps_api/models/edit_package_campaign.rb', line 23

def mail_owner_name
  @mail_owner_name
end

#midString

The Mailer ID associated with the campaign.

Returns:

  • (String)


14
15
16
# File 'lib/usps_api/models/edit_package_campaign.rb', line 14

def mid
  @mid
end

#ride_alongString

The image that is displayed for packages matched with a package campaign. When clicked, this image will take users to the Target URL of the campaign. This field is required.

Returns:

  • (String)


62
63
64
# File 'lib/usps_api/models/edit_package_campaign.rb', line 62

def ride_along
  @ride_along
end

#start_dateDate

First day campaign will be displayed

Returns:

  • (Date)


47
48
49
# File 'lib/usps_api/models/edit_package_campaign.rb', line 47

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


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

def target_url
  @target_url
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



126
127
128
129
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
# File 'lib/usps_api/models/edit_package_campaign.rb', line 126

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  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_grouping_code =
    hash.key?('campaignGroupingCode') ? hash['campaignGroupingCode'] : 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
  target_url = hash.key?('targetUrl') ? hash['targetUrl'] : SKIP
  ride_along = hash.key?('rideAlong') ? hash['rideAlong'] : 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.
  EditPackageCampaign.new(mid: mid,
                          mail_owner_crid: mail_owner_crid,
                          mail_owner_name: mail_owner_name,
                          campaign_code: campaign_code,
                          campaign_grouping_code: campaign_grouping_code,
                          campaign_title: campaign_title,
                          brand_display_name: brand_display_name,
                          start_date: start_date,
                          end_date: end_date,
                          target_url: target_url,
                          ride_along: ride_along,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/usps_api/models/edit_package_campaign.rb', line 65

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['mid'] = 'MID'
  @_hash['mail_owner_crid'] = 'mailOwnerCRID'
  @_hash['mail_owner_name'] = 'mailOwnerName'
  @_hash['campaign_code'] = 'campaignCode'
  @_hash['campaign_grouping_code'] = 'campaignGroupingCode'
  @_hash['campaign_title'] = 'campaignTitle'
  @_hash['brand_display_name'] = 'brandDisplayName'
  @_hash['start_date'] = 'startDate'
  @_hash['end_date'] = 'endDate'
  @_hash['target_url'] = 'targetUrl'
  @_hash['ride_along'] = 'rideAlong'
  @_hash
end

.nullablesObject

An array for nullable fields



99
100
101
# File 'lib/usps_api/models/edit_package_campaign.rb', line 99

def self.nullables
  []
end

.optionalsObject

An array for optional fields



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/usps_api/models/edit_package_campaign.rb', line 82

def self.optionals
  %w[
    mid
    mail_owner_crid
    mail_owner_name
    campaign_code
    campaign_grouping_code
    campaign_title
    brand_display_name
    start_date
    end_date
    target_url
    ride_along
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



180
181
182
183
184
185
186
187
188
189
# File 'lib/usps_api/models/edit_package_campaign.rb', line 180

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

#to_sObject

Provides a human-readable string representation of the object.



169
170
171
172
173
174
175
176
177
# File 'lib/usps_api/models/edit_package_campaign.rb', line 169

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