Class: AdvancedBilling::ChargifyEBB

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/advanced_billing/models/chargify_ebb.rb

Overview

ChargifyEBB 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(timestamp: SKIP, id: SKIP, created_at: SKIP, uniqueness_token: SKIP, subscription_id: SKIP, subscription_reference: SKIP, additional_properties: {}) ⇒ ChargifyEBB

Returns a new instance of ChargifyEBB.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 79

def initialize(timestamp: SKIP, id: SKIP, created_at: SKIP,
               uniqueness_token: SKIP, subscription_id: SKIP,
               subscription_reference: SKIP, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @timestamp = timestamp unless timestamp == SKIP
  @id = id unless id == SKIP
  @created_at = created_at unless created_at == SKIP
  @uniqueness_token = uniqueness_token unless uniqueness_token == SKIP
  @subscription_id = subscription_id unless subscription_id == SKIP
  @subscription_reference = subscription_reference unless subscription_reference == SKIP
end

Instance Attribute Details

#created_atDateTime

An ISO-8601 timestamp, set by Chargify at the time each event is recorded. Please note that this field is reserved. If ‘chargify.created_at` is present in the request payload, it will be overwritten.

Returns:

  • (DateTime)


28
29
30
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 28

def created_at
  @created_at
end

#idString

A unique ID set by Chargify. Please note that this field is reserved. If ‘chargify.id` is present in the request payload, it will be overwritten.

Returns:

  • (String)


22
23
24
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 22

def id
  @id
end

#subscription_idInteger

Id of Maxio Advanced Billing Subscription which is connected to this event. Provide ‘subscription_id` if you configured `chargify.subscription_id` as Subscription Identifier in your Event Stream.

Returns:

  • (Integer)


40
41
42
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 40

def subscription_id
  @subscription_id
end

#subscription_referenceString

Reference of Maxio Advanced Billing Subscription which is connected to this event. Provide ‘subscription_reference` if you configured `chargify.subscription_reference` as Subscription Identifier in your Event Stream.

Returns:

  • (String)


48
49
50
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 48

def subscription_reference
  @subscription_reference
end

#timestampDateTime

This timestamp determines what billing period the event will be billed in. If your request payload does not include it, Chargify will add ‘chargify.timestamp` to the event payload and set the value to `now`.

Returns:

  • (DateTime)


17
18
19
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 17

def timestamp
  @timestamp
end

#uniqueness_tokenString

User-defined string scoped per-stream. Duplicate events within a stream will be silently ignored. Tokens expire after 31 days.

Returns:

  • (String)


33
34
35
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 33

def uniqueness_token
  @uniqueness_token
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 96

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  timestamp = if hash.key?('timestamp')
                (DateTimeHelper.from_rfc3339(hash['timestamp']) if hash['timestamp'])
              else
                SKIP
              end
  id = hash.key?('id') ? hash['id'] : SKIP
  created_at = if hash.key?('created_at')
                 (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at'])
               else
                 SKIP
               end
  uniqueness_token =
    hash.key?('uniqueness_token') ? hash['uniqueness_token'] : SKIP
  subscription_id =
    hash.key?('subscription_id') ? hash['subscription_id'] : SKIP
  subscription_reference =
    hash.key?('subscription_reference') ? hash['subscription_reference'] : SKIP

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  ChargifyEBB.new(timestamp: timestamp,
                  id: id,
                  created_at: created_at,
                  uniqueness_token: uniqueness_token,
                  subscription_id: subscription_id,
                  subscription_reference: subscription_reference,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



51
52
53
54
55
56
57
58
59
60
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 51

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['timestamp'] = 'timestamp'
  @_hash['id'] = 'id'
  @_hash['created_at'] = 'created_at'
  @_hash['uniqueness_token'] = 'uniqueness_token'
  @_hash['subscription_id'] = 'subscription_id'
  @_hash['subscription_reference'] = 'subscription_reference'
  @_hash
end

.nullablesObject

An array for nullable fields



75
76
77
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 75

def self.nullables
  []
end

.optionalsObject

An array for optional fields



63
64
65
66
67
68
69
70
71
72
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 63

def self.optionals
  %w[
    timestamp
    id
    created_at
    uniqueness_token
    subscription_id
    subscription_reference
  ]
end

Instance Method Details

#to_custom_created_atObject



135
136
137
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 135

def to_custom_created_at
  DateTimeHelper.to_rfc3339(created_at)
end

#to_custom_timestampObject



131
132
133
# File 'lib/advanced_billing/models/chargify_ebb.rb', line 131

def to_custom_timestamp
  DateTimeHelper.to_rfc3339(timestamp)
end