Class: ApiReference::EvaluateMultiplePricesWithPreviewEventsBody

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb

Overview

EvaluateMultiplePricesWithPreviewEventsBody 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(timeframe_start:, timeframe_end:, customer_id: SKIP, external_customer_id: SKIP, events: SKIP, price_evaluations: SKIP) ⇒ EvaluateMultiplePricesWithPreviewEventsBody

Returns a new instance of EvaluateMultiplePricesWithPreviewEventsBody.



68
69
70
71
72
73
74
75
76
77
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 68

def initialize(timeframe_start:, timeframe_end:, customer_id: SKIP,
               external_customer_id: SKIP, events: SKIP,
               price_evaluations: SKIP)
  @customer_id = customer_id unless customer_id == SKIP
  @external_customer_id = external_customer_id unless external_customer_id == SKIP
  @timeframe_start = timeframe_start
  @timeframe_end = timeframe_end
  @events = events unless events == SKIP
  @price_evaluations = price_evaluations unless price_evaluations == SKIP
end

Instance Attribute Details

#customer_idString

The ID of the customer to which this evaluation is scoped.

Returns:

  • (String)


15
16
17
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 15

def customer_id
  @customer_id
end

#eventsArray[PreviewEvent]

List of preview events to use instead of actual usage data

Returns:



32
33
34
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 32

def events
  @events
end

#external_customer_idString

The external customer ID of the customer to which this evaluation is scoped.

Returns:

  • (String)


20
21
22
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 20

def external_customer_id
  @external_customer_id
end

#price_evaluationsArray[PriceEvaluationRequest]

List of prices to evaluate (max 100)

Returns:



36
37
38
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 36

def price_evaluations
  @price_evaluations
end

#timeframe_endDateTime

The exclusive upper bound for event timestamps

Returns:

  • (DateTime)


28
29
30
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 28

def timeframe_end
  @timeframe_end
end

#timeframe_startDateTime

The inclusive lower bound for event timestamps

Returns:

  • (DateTime)


24
25
26
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 24

def timeframe_start
  @timeframe_start
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
112
113
114
115
116
117
118
119
120
121
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 80

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  timeframe_start = if hash.key?('timeframe_start')
                      (DateTimeHelper.from_rfc3339(hash['timeframe_start']) if hash['timeframe_start'])
                    end
  timeframe_end = if hash.key?('timeframe_end')
                    (DateTimeHelper.from_rfc3339(hash['timeframe_end']) if hash['timeframe_end'])
                  end
  customer_id = hash.key?('customer_id') ? hash['customer_id'] : SKIP
  external_customer_id =
    hash.key?('external_customer_id') ? hash['external_customer_id'] : SKIP
  # Parameter is an array, so we need to iterate through it
  events = nil
  unless hash['events'].nil?
    events = []
    hash['events'].each do |structure|
      events << (PreviewEvent.from_hash(structure) if structure)
    end
  end

  events = SKIP unless hash.key?('events')
  # Parameter is an array, so we need to iterate through it
  price_evaluations = nil
  unless hash['price_evaluations'].nil?
    price_evaluations = []
    hash['price_evaluations'].each do |structure|
      price_evaluations << (PriceEvaluationRequest.from_hash(structure) if structure)
    end
  end

  price_evaluations = SKIP unless hash.key?('price_evaluations')

  # Create object from extracted values.
  EvaluateMultiplePricesWithPreviewEventsBody.new(timeframe_start: timeframe_start,
                                                  timeframe_end: timeframe_end,
                                                  customer_id: customer_id,
                                                  external_customer_id: external_customer_id,
                                                  events: events,
                                                  price_evaluations: price_evaluations)
end

.namesObject

A mapping from model property names to API property names.



39
40
41
42
43
44
45
46
47
48
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 39

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['customer_id'] = 'customer_id'
  @_hash['external_customer_id'] = 'external_customer_id'
  @_hash['timeframe_start'] = 'timeframe_start'
  @_hash['timeframe_end'] = 'timeframe_end'
  @_hash['events'] = 'events'
  @_hash['price_evaluations'] = 'price_evaluations'
  @_hash
end

.nullablesObject

An array for nullable fields



61
62
63
64
65
66
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 61

def self.nullables
  %w[
    customer_id
    external_customer_id
  ]
end

.optionalsObject

An array for optional fields



51
52
53
54
55
56
57
58
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 51

def self.optionals
  %w[
    customer_id
    external_customer_id
    events
    price_evaluations
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



140
141
142
143
144
145
146
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 140

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} customer_id: #{@customer_id.inspect}, external_customer_id:"\
  " #{@external_customer_id.inspect}, timeframe_start: #{@timeframe_start.inspect},"\
  " timeframe_end: #{@timeframe_end.inspect}, events: #{@events.inspect}, price_evaluations:"\
  " #{@price_evaluations.inspect}>"
end

#to_custom_timeframe_endObject



127
128
129
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 127

def to_custom_timeframe_end
  DateTimeHelper.to_rfc3339(timeframe_end)
end

#to_custom_timeframe_startObject



123
124
125
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 123

def to_custom_timeframe_start
  DateTimeHelper.to_rfc3339(timeframe_start)
end

#to_sObject

Provides a human-readable string representation of the object.



132
133
134
135
136
137
# File 'lib/api_reference/models/evaluate_multiple_prices_with_preview_events_body.rb', line 132

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} customer_id: #{@customer_id}, external_customer_id:"\
  " #{@external_customer_id}, timeframe_start: #{@timeframe_start}, timeframe_end:"\
  " #{@timeframe_end}, events: #{@events}, price_evaluations: #{@price_evaluations}>"
end