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

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(id:, pricing_scheme:, prices:, additional_properties: {}) ⇒ BulkUpdateSegmentsItem

Returns a new instance of BulkUpdateSegmentsItem.



47
48
49
50
51
52
53
54
55
56
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 47

def initialize(id:, pricing_scheme:, prices:, additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @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 identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.

Returns:



26
27
28
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 26

def prices
  @prices
end

#pricing_schemePricingScheme

The identifier for the pricing scheme. See [Product Components](help.chargify.com/products/product-components.html) for an overview of pricing schemes.

Returns:



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

def pricing_scheme
  @pricing_scheme
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 59

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')

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

  # Create object from extracted values.
  BulkUpdateSegmentsItem.new(id: id,
                             pricing_scheme: pricing_scheme,
                             prices: prices,
                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

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



43
44
45
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



38
39
40
# File 'lib/advanced_billing/models/bulk_update_segments_item.rb', line 38

def self.optionals
  []
end