Class: UspsApi::CallbackKey

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

Overview

CallbackKey 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(callback_key: SKIP, campaign_id: SKIP, submitter_crid: SKIP, submitter_transaction_id: SKIP, submitted_datetime: SKIP, total_barcodes: SKIP, total_barcodes_added: SKIP, total_barcodes_failed: SKIP, expiration_datetime: SKIP, processing_status: SKIP, active: SKIP, additional_properties: nil) ⇒ CallbackKey

Returns a new instance of CallbackKey.



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

def initialize(callback_key: SKIP, campaign_id: SKIP, submitter_crid: SKIP,
               submitter_transaction_id: SKIP, submitted_datetime: SKIP,
               total_barcodes: SKIP, total_barcodes_added: SKIP,
               total_barcodes_failed: SKIP, expiration_datetime: SKIP,
               processing_status: SKIP, active: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @callback_key = callback_key unless callback_key == SKIP
  @campaign_id = campaign_id unless campaign_id == SKIP
  @submitter_crid = submitter_crid unless submitter_crid == SKIP
  @submitter_transaction_id = submitter_transaction_id unless submitter_transaction_id == SKIP
  @submitted_datetime =  unless  == SKIP
  @total_barcodes = total_barcodes unless total_barcodes == SKIP
  @total_barcodes_added = total_barcodes_added unless total_barcodes_added == SKIP
  @total_barcodes_failed = total_barcodes_failed unless total_barcodes_failed == SKIP
  @expiration_datetime = expiration_datetime unless expiration_datetime == SKIP
  @processing_status = processing_status unless processing_status == SKIP
  @active = active unless active == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#activeTrueClass | FalseClass

Indicator field for whether details on the callback key transaction can still be returned based on whether the expiration date is in the future or past. If a transaction is no longer active, an error will be returned if an integrator attempts to get summary or detail-level details on the callback key.

Returns:

  • (TrueClass | FalseClass)


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

def active
  @active
end

#callback_keyString

The callback key associated with the Add Many IMB transaction.

Returns:

  • (String)


15
16
17
# File 'lib/usps_api/models/callback_key.rb', line 15

def callback_key
  @callback_key
end

#campaign_idString

The campaign ID associated with the callback key transaction.

Returns:

  • (String)


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

def campaign_id
  @campaign_id
end

#expiration_datetimeDateTime

Date of time that information on the callback key transaction is no longer available to be queried by the integrator. Callback key transactions expire 60 days after they are originally submitted.

Returns:

  • (DateTime)


52
53
54
# File 'lib/usps_api/models/callback_key.rb', line 52

def expiration_datetime
  @expiration_datetime
end

#processing_statusString

The processing status of the callback key transaction. This field can be SUBMITTED, PROCESSING, COMPLETE-ERRORS, COMPLETE-NOERRORS, or SYSTEM-FAILURE. Summary level and detail level details cannot be returned for a callback key if its status is still SUBMITTED or PROCESSING. If a transaction is still processing, an error will be returned if an integrator attempts to get summary or detail-level details on the callback key.

Returns:

  • (String)


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

def processing_status
  @processing_status
end

#submitted_datetimeDateTime

Date and time of the callback key transaction.

Returns:

  • (DateTime)


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

def 
  @submitted_datetime
end

#submitter_cridString

The submitter’s CRID.

Returns:

  • (String)


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

def submitter_crid
  @submitter_crid
end

#submitter_transaction_idString

The submitter’s transaction ID associated with the callback key transaction.

Returns:

  • (String)


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

def submitter_transaction_id
  @submitter_transaction_id
end

#total_barcodesFloat

The total number of barcodes in the callback key transaction.

Returns:

  • (Float)


36
37
38
# File 'lib/usps_api/models/callback_key.rb', line 36

def total_barcodes
  @total_barcodes
end

#total_barcodes_addedFloat

The total number of barcodes successfully added to the campaign via the callback key transaction.

Returns:

  • (Float)


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

def total_barcodes_added
  @total_barcodes_added
end

#total_barcodes_failedFloat

The total number of barcodes that failed to be added to the campaign via the callback key transaction.

Returns:

  • (Float)


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

def total_barcodes_failed
  @total_barcodes_failed
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/usps_api/models/callback_key.rb', line 135

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  callback_key = hash.key?('callbackKey') ? hash['callbackKey'] : SKIP
  campaign_id = hash.key?('campaignID') ? hash['campaignID'] : SKIP
  submitter_crid = hash.key?('submitterCRID') ? hash['submitterCRID'] : SKIP
  submitter_transaction_id =
    hash.key?('submitterTransactionID') ? hash['submitterTransactionID'] : SKIP
   = if hash.key?('submittedDatetime')
                         (DateTimeHelper.from_rfc3339(hash['submittedDatetime']) if hash['submittedDatetime'])
                       else
                         SKIP
                       end
  total_barcodes = hash.key?('totalBarcodes') ? hash['totalBarcodes'] : SKIP
  total_barcodes_added =
    hash.key?('totalBarcodesAdded') ? hash['totalBarcodesAdded'] : SKIP
  total_barcodes_failed =
    hash.key?('totalBarcodesFailed') ? hash['totalBarcodesFailed'] : SKIP
  expiration_datetime = if hash.key?('expirationDatetime')
                          (DateTimeHelper.from_rfc3339(hash['expirationDatetime']) if hash['expirationDatetime'])
                        else
                          SKIP
                        end
  processing_status =
    hash.key?('processingStatus') ? hash['processingStatus'] : SKIP
  active = hash.key?('active') ? hash['active'] : 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.
  CallbackKey.new(callback_key: callback_key,
                  campaign_id: campaign_id,
                  submitter_crid: submitter_crid,
                  submitter_transaction_id: submitter_transaction_id,
                  submitted_datetime: ,
                  total_barcodes: total_barcodes,
                  total_barcodes_added: total_barcodes_added,
                  total_barcodes_failed: total_barcodes_failed,
                  expiration_datetime: expiration_datetime,
                  processing_status: processing_status,
                  active: active,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/usps_api/models/callback_key.rb', line 73

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['callback_key'] = 'callbackKey'
  @_hash['campaign_id'] = 'campaignID'
  @_hash['submitter_crid'] = 'submitterCRID'
  @_hash['submitter_transaction_id'] = 'submitterTransactionID'
  @_hash['submitted_datetime'] = 'submittedDatetime'
  @_hash['total_barcodes'] = 'totalBarcodes'
  @_hash['total_barcodes_added'] = 'totalBarcodesAdded'
  @_hash['total_barcodes_failed'] = 'totalBarcodesFailed'
  @_hash['expiration_datetime'] = 'expirationDatetime'
  @_hash['processing_status'] = 'processingStatus'
  @_hash['active'] = 'active'
  @_hash
end

.nullablesObject

An array for nullable fields



107
108
109
# File 'lib/usps_api/models/callback_key.rb', line 107

def self.nullables
  []
end

.optionalsObject

An array for optional fields



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/usps_api/models/callback_key.rb', line 90

def self.optionals
  %w[
    callback_key
    campaign_id
    submitter_crid
    submitter_transaction_id
    submitted_datetime
    total_barcodes
    total_barcodes_added
    total_barcodes_failed
    expiration_datetime
    processing_status
    active
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



206
207
208
209
210
211
212
213
214
215
216
# File 'lib/usps_api/models/callback_key.rb', line 206

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} callback_key: #{@callback_key.inspect}, campaign_id:"\
  " #{@campaign_id.inspect}, submitter_crid: #{@submitter_crid.inspect},"\
  " submitter_transaction_id: #{@submitter_transaction_id.inspect}, submitted_datetime:"\
  " #{@submitted_datetime.inspect}, total_barcodes: #{@total_barcodes.inspect},"\
  " total_barcodes_added: #{@total_barcodes_added.inspect}, total_barcodes_failed:"\
  " #{@total_barcodes_failed.inspect}, expiration_datetime: #{@expiration_datetime.inspect},"\
  " processing_status: #{@processing_status.inspect}, active: #{@active.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_expiration_datetimeObject



189
190
191
# File 'lib/usps_api/models/callback_key.rb', line 189

def to_custom_expiration_datetime
  DateTimeHelper.to_rfc3339(expiration_datetime)
end

#to_custom_submitted_datetimeObject



185
186
187
# File 'lib/usps_api/models/callback_key.rb', line 185

def 
  DateTimeHelper.to_rfc3339()
end

#to_sObject

Provides a human-readable string representation of the object.



194
195
196
197
198
199
200
201
202
203
# File 'lib/usps_api/models/callback_key.rb', line 194

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} callback_key: #{@callback_key}, campaign_id: #{@campaign_id},"\
  " submitter_crid: #{@submitter_crid}, submitter_transaction_id:"\
  " #{@submitter_transaction_id}, submitted_datetime: #{@submitted_datetime}, total_barcodes:"\
  " #{@total_barcodes}, total_barcodes_added: #{@total_barcodes_added}, total_barcodes_failed:"\
  " #{@total_barcodes_failed}, expiration_datetime: #{@expiration_datetime},"\
  " processing_status: #{@processing_status}, active: #{@active}, additional_properties:"\
  " #{@additional_properties}>"
end