Class: ApiReference::SubscriptionUsageRequestParams

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

Overview

SubscriptionUsageRequestParams 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(granularity: Granularity::DAY, timeframe_start: SKIP, timeframe_end: SKIP, billable_metric_id: SKIP, group_by: SKIP, view_mode: SKIP, first_dimension_key: SKIP, first_dimension_value: SKIP, second_dimension_key: SKIP, second_dimension_value: SKIP) ⇒ SubscriptionUsageRequestParams

Returns a new instance of SubscriptionUsageRequestParams.



118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 118

def initialize(granularity: Granularity::DAY, timeframe_start: SKIP,
               timeframe_end: SKIP, billable_metric_id: SKIP,
               group_by: SKIP, view_mode: SKIP, first_dimension_key: SKIP,
               first_dimension_value: SKIP, second_dimension_key: SKIP,
               second_dimension_value: SKIP)
  @granularity = granularity unless granularity == SKIP
  @timeframe_start = timeframe_start unless timeframe_start == SKIP
  @timeframe_end = timeframe_end unless timeframe_end == SKIP
  @billable_metric_id = billable_metric_id unless billable_metric_id == SKIP
  @group_by = group_by unless group_by == SKIP
  @view_mode = view_mode unless view_mode == SKIP
  @first_dimension_key = first_dimension_key unless first_dimension_key == SKIP
  @first_dimension_value = first_dimension_value unless first_dimension_value == SKIP
  @second_dimension_key = second_dimension_key unless second_dimension_key == SKIP
  @second_dimension_value = second_dimension_value unless second_dimension_value == SKIP
end

Instance Attribute Details

#billable_metric_idString

When specified in conjunction with group_by, this parameter filters usage to a single billable metric. Note that both group_by and billable_metric_id must be specified together.

Returns:

  • (String)


29
30
31
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 29

def billable_metric_id
  @billable_metric_id
end

#first_dimension_keyString

Controls whether Orb returns cumulative usage since the start of the billing period, or incremental day-by-day usage. If your customer has minimums or discounts, it's strongly recommended that you use the default cumulative behavior.

Returns:

  • (String)


47
48
49
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 47

def first_dimension_key
  @first_dimension_key
end

#first_dimension_valueString

Controls whether Orb returns cumulative usage since the start of the billing period, or incremental day-by-day usage. If your customer has minimums or discounts, it's strongly recommended that you use the default cumulative behavior.

Returns:

  • (String)


54
55
56
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 54

def first_dimension_value
  @first_dimension_value
end

#granularityGranularity

This determines the windowing of usage reporting.

Returns:



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

def granularity
  @granularity
end

#group_byString

Groups per-price usage by the key provided.

Returns:

  • (String)


33
34
35
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 33

def group_by
  @group_by
end

#second_dimension_keyString

Controls whether Orb returns cumulative usage since the start of the billing period, or incremental day-by-day usage. If your customer has minimums or discounts, it's strongly recommended that you use the default cumulative behavior.

Returns:

  • (String)


61
62
63
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 61

def second_dimension_key
  @second_dimension_key
end

#second_dimension_valueString

Controls whether Orb returns cumulative usage since the start of the billing period, or incremental day-by-day usage. If your customer has minimums or discounts, it's strongly recommended that you use the default cumulative behavior.

Returns:

  • (String)


68
69
70
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 68

def second_dimension_value
  @second_dimension_value
end

#timeframe_endDateTime

Usage returned is exclusive of timeframe_end.

Returns:

  • (DateTime)


23
24
25
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 23

def timeframe_end
  @timeframe_end
end

#timeframe_startDateTime

Usage returned is inclusive of timeframe_start.

Returns:

  • (DateTime)


19
20
21
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 19

def timeframe_start
  @timeframe_start
end

#view_modeViewMode

Controls whether Orb returns cumulative usage since the start of the billing period, or incremental day-by-day usage. If your customer has minimums or discounts, it's strongly recommended that you use the default cumulative behavior.

Returns:



40
41
42
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 40

def view_mode
  @view_mode
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 136

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  granularity = hash['granularity'] ||= Granularity::DAY
  timeframe_start = if hash.key?('timeframe_start')
                      (DateTimeHelper.from_rfc3339(hash['timeframe_start']) if hash['timeframe_start'])
                    else
                      SKIP
                    end
  timeframe_end = if hash.key?('timeframe_end')
                    (DateTimeHelper.from_rfc3339(hash['timeframe_end']) if hash['timeframe_end'])
                  else
                    SKIP
                  end
  billable_metric_id =
    hash.key?('billable_metric_id') ? hash['billable_metric_id'] : SKIP
  group_by = hash.key?('group_by') ? hash['group_by'] : SKIP
  view_mode = hash.key?('view_mode') ? hash['view_mode'] : SKIP
  first_dimension_key =
    hash.key?('first_dimension_key') ? hash['first_dimension_key'] : SKIP
  first_dimension_value =
    hash.key?('first_dimension_value') ? hash['first_dimension_value'] : SKIP
  second_dimension_key =
    hash.key?('second_dimension_key') ? hash['second_dimension_key'] : SKIP
  second_dimension_value =
    hash.key?('second_dimension_value') ? hash['second_dimension_value'] : SKIP

  # Create object from extracted values.
  SubscriptionUsageRequestParams.new(granularity: granularity,
                                     timeframe_start: timeframe_start,
                                     timeframe_end: timeframe_end,
                                     billable_metric_id: billable_metric_id,
                                     group_by: group_by,
                                     view_mode: view_mode,
                                     first_dimension_key: first_dimension_key,
                                     first_dimension_value: first_dimension_value,
                                     second_dimension_key: second_dimension_key,
                                     second_dimension_value: second_dimension_value)
end

.namesObject

A mapping from model property names to API property names.



71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 71

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['granularity'] = 'granularity'
  @_hash['timeframe_start'] = 'timeframe_start'
  @_hash['timeframe_end'] = 'timeframe_end'
  @_hash['billable_metric_id'] = 'billable_metric_id'
  @_hash['group_by'] = 'group_by'
  @_hash['view_mode'] = 'view_mode'
  @_hash['first_dimension_key'] = 'first_dimension_key'
  @_hash['first_dimension_value'] = 'first_dimension_value'
  @_hash['second_dimension_key'] = 'second_dimension_key'
  @_hash['second_dimension_value'] = 'second_dimension_value'
  @_hash
end

.nullablesObject

An array for nullable fields



103
104
105
106
107
108
109
110
111
112
113
114
115
116
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 103

def self.nullables
  %w[
    granularity
    timeframe_start
    timeframe_end
    billable_metric_id
    group_by
    view_mode
    first_dimension_key
    first_dimension_value
    second_dimension_key
    second_dimension_value
  ]
end

.optionalsObject

An array for optional fields



87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 87

def self.optionals
  %w[
    granularity
    timeframe_start
    timeframe_end
    billable_metric_id
    group_by
    view_mode
    first_dimension_key
    first_dimension_value
    second_dimension_key
    second_dimension_value
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



196
197
198
199
200
201
202
203
204
205
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 196

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} granularity: #{@granularity.inspect}, timeframe_start:"\
  " #{@timeframe_start.inspect}, timeframe_end: #{@timeframe_end.inspect}, billable_metric_id:"\
  " #{@billable_metric_id.inspect}, group_by: #{@group_by.inspect}, view_mode:"\
  " #{@view_mode.inspect}, first_dimension_key: #{@first_dimension_key.inspect},"\
  " first_dimension_value: #{@first_dimension_value.inspect}, second_dimension_key:"\
  " #{@second_dimension_key.inspect}, second_dimension_value:"\
  " #{@second_dimension_value.inspect}>"
end

#to_custom_timeframe_endObject



181
182
183
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 181

def to_custom_timeframe_end
  DateTimeHelper.to_rfc3339(timeframe_end)
end

#to_custom_timeframe_startObject



177
178
179
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 177

def to_custom_timeframe_start
  DateTimeHelper.to_rfc3339(timeframe_start)
end

#to_sObject

Provides a human-readable string representation of the object.



186
187
188
189
190
191
192
193
# File 'lib/api_reference/models/subscription_usage_request_params.rb', line 186

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} granularity: #{@granularity}, timeframe_start: #{@timeframe_start},"\
  " timeframe_end: #{@timeframe_end}, billable_metric_id: #{@billable_metric_id}, group_by:"\
  " #{@group_by}, view_mode: #{@view_mode}, first_dimension_key: #{@first_dimension_key},"\
  " first_dimension_value: #{@first_dimension_value}, second_dimension_key:"\
  " #{@second_dimension_key}, second_dimension_value: #{@second_dimension_value}>"
end