Class: AdvancedBilling::BulkUpdateSegmentsItem

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

Overview

BulkUpdateSegmentsItem Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(id = nil, pricing_scheme = nil, prices = nil) ⇒ BulkUpdateSegmentsItem

Returns a new instance of BulkUpdateSegmentsItem.



49
50
51
52
53
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 49

def initialize(id = nil, pricing_scheme = nil, prices = nil)
  @id = id
  @pricing_scheme = pricing_scheme
  @prices = prices
end

Instance Attribute Details

#idInteger

The ID of the segment you want to update.

Returns:

  • (Integer)


14
15
16
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 14

def id
  @id
end

#pricesArray[CreateOrUpdateSegmentPrice]

The handle for the pricing scheme. Available options: per_unit, volume, tiered, stairstep. See [Price Bracket Rules](help.chargify.com/products/product-components.html#price-br acket-rules) for an overview of pricing schemes.

Returns:



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

def prices
  @prices
end

#pricing_schemeString

The handle for the pricing scheme. Available options: per_unit, volume, tiered, stairstep. See [Price Bracket Rules](help.chargify.com/products/product-components.html#price-br acket-rules) for an overview of pricing schemes.

Returns:

  • (String)


21
22
23
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 21

def pricing_scheme
  @pricing_scheme
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.

  id = hash.key?('id') ? hash['id'] : nil
  pricing_scheme =
    hash.key?('pricing_scheme') ? hash['pricing_scheme'] : nil
  # Parameter is an array, so we need to iterate through it

  prices = nil
  unless hash['prices'].nil?
    prices = []
    hash['prices'].each do |structure|
      prices << (CreateOrUpdateSegmentPrice.from_hash(structure) if structure)
    end
  end

  prices = nil unless hash.key?('prices')

  # Create object from extracted values.

  BulkUpdateSegmentsItem.new(id,
                             pricing_scheme,
                             prices)
end

.namesObject

A mapping from model property names to API property names.



31
32
33
34
35
36
37
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 31

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['id'] = 'id'
  @_hash['pricing_scheme'] = 'pricing_scheme'
  @_hash['prices'] = 'prices'
  @_hash
end

.nullablesObject

An array for nullable fields



45
46
47
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 45

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  []
end