class Bfwd::TieredPricingComponent

Attributes

changed_by[RW]

{ "description" : "ID of the user who last updated the entity.", "verbs":[] }

charge_model[RW]

{ "description" : "The charge model of the pricing-component.", "verbs":["POST","PUT","GET"] }

charge_type[RW]

{ "description" : "The charge type of the pricing-component.", "verbs":["POST","PUT","GET"] }

created[RW]

{ "description" : "The UTC DateTime when the object was created.", "verbs":[] }

crm_id[RW]

{ "description" : "", "verbs":["POST","PUT","GET"] }

default_quantity[RW]

{ "description" : "The default quantity of the pricing-component. If no value is supplied on a subscription this value will be used. This is useful for setting an expected purchase level of for introducing new pricing components to existing subscriptions and not having to back-fill values", "verbs":["POST","PUT","GET"] }

description[RW]

{ "description" : "", "verbs":["POST","PUT","GET"] }

downgrade_mode[RW]

{"default":"<span class=\"label label-default\">delayed</span>","description":"Default behaviour when a value is downgraded using this pricing component, this behaviour can be overridden when changing the value.
<span class=\"label label-default\">immediate</span> &mdash; Downgrade will apply at the time the request is made.
<span class=\"label label-default\">delayed</span> &mdash; Downgrade will apply at the end of the current billing cycle.","verbs":}

id[RW]

{ "description" : "", "verbs":["GET"] } When associating a pricing component with a product rate plan, this ID should be used.

invoicing_type[RW]

{ "default" : "Aggregated", "description" : "For <span class=\"label label-default\">setup</span> pricing components <span class=\"label label-default\">Immediate</span> invoicing will result in an invoice being issued on subscription being set to the AwaitingPayment state, irrespective of the subscription start date. <span class=\"label label-default\">Aggregated</span> invoicing will add a charge to the first invoice of the subscription.", "verbs":["POST","PUT","GET"] }

max_quantity[RW]

{ "description" : "The maximum quantity of the pricing-component.", "verbs":[] }

min_quantity[RW]

{ "default" : "0", "description" : "The minimum quantity of the pricing-component.", "verbs":[] }

name[RW]

{ "description" : "", "verbs":["POST","PUT","GET"] }

organization_id[RW]

{ "description" : "", "verbs":[] }

product_rate_plan_id[RW]

{ "description" : "", "verbs":["POST","PUT","GET"] }

public_name[RW]

{"description":"A friendly non-unique name used to identify this pricing-component","verbs":}

tiers[RW]

{ "default" : "[]", "description" : "The pricing-component-tiers associated with the pricing-component.", "verbs":["POST","PUT","GET"] }

type[RW]

{ "description" : "", "default" : "", "verbs":["POST","GET"] }

unit_of_measure[RW]

{ "description" : "The unit-of-measure associated with the pricing-component.", "verbs":["POST","PUT","GET"] }

unit_of_measure_id[RW]

{ "description" : "", "verbs":["POST","PUT","GET"] }

updated[RW]

{ "description" : "The UTC DateTime when the object was last updated.", "verbs":[] }

upgrade_mode[RW]

{"default":"<span class=\"label label-default\">immediate</span>","description":"Default behaviour when a value is upgraded using this pricing component, this behaviour can be overridden when changing the value.
<span class=\"label label-default\">immediate</span> &mdash; Upgrade will apply at the time the request is made.
<span class=\"label label-default\">delayed</span> &mdash; Upgrade will apply at the end of the current billing cycle.","verbs":}

valid_from[RW]

{ "default" : "current time", "description" : "The DateTime specifying when the pricing-component is valid from.", "verbs":["POST","PUT","GET"] }

valid_till[RW]

{ "default" : "null", "description" : "The UTC DateTime specifying when the pricing-component is valid till.", "verbs":["POST","PUT","GET"] }

version_id[RW]

{ "description" : "", "verbs":["GET"] }

Public Class Methods

attribute_map() click to toggle source

Attribute mapping from ruby-style variable name to JSON key.

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 116
def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'updated' => :'updated',
    :'type' => :'@type',
    :'version_id' => :'versionID',
    :'crm_id' => :'crmID',
    :'id' => :'id',
    :'product_rate_plan_id' => :'productRatePlanID',
    :'unit_of_measure_id' => :'unitOfMeasureID',
    :'organization_id' => :'organizationID',
    :'name' => :'name',
    :'public_name' => :'publicName',
    :'description' => :'description',
    :'charge_type' => :'chargeType',
    :'invoicing_type' => :'invoicingType',
    :'charge_model' => :'chargeModel',
    :'upgrade_mode' => :'upgradeMode',
    :'downgrade_mode' => :'downgradeMode',
    :'default_quantity' => :'defaultQuantity',
    :'min_quantity' => :'minQuantity',
    :'max_quantity' => :'maxQuantity',
    :'valid_from' => :'validFrom',
    :'valid_till' => :'validTill',
    :'tiers' => :'tiers',
    :'unit_of_measure' => :'unitOfMeasure'
  }
end
new(attributes = {}) click to toggle source

Initializes the object @param [Hash] attributes Model attributes in the form of hash

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 179
def initialize(attributes = {})
  return unless attributes.is_a?(Hash)

  # convert string to symbol for hash key
  attributes = attributes.each_with_object({}){|(k,v), h| h[k.to_sym] = v}

  if attributes.has_key?(:'created')
    self.created = attributes[:'created']
  end

  if attributes.has_key?(:'changedBy')
    self.changed_by = attributes[:'changedBy']
  end

  if attributes.has_key?(:'updated')
    self.updated = attributes[:'updated']
  end

  if attributes.has_key?(:'@type')
    self.type = attributes[:'@type']
  end

  if attributes.has_key?(:'versionID')
    self.version_id = attributes[:'versionID']
  end

  if attributes.has_key?(:'crmID')
    self.crm_id = attributes[:'crmID']
  end

  if attributes.has_key?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.has_key?(:'productRatePlanID')
    self.product_rate_plan_id = attributes[:'productRatePlanID']
  end

  if attributes.has_key?(:'unitOfMeasureID')
    self.unit_of_measure_id = attributes[:'unitOfMeasureID']
  end

  if attributes.has_key?(:'organizationID')
    self.organization_id = attributes[:'organizationID']
  end

  if attributes.has_key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.has_key?(:'publicName')
    self.public_name = attributes[:'publicName']
  end

  if attributes.has_key?(:'description')
    self.description = attributes[:'description']
  end

  if attributes.has_key?(:'chargeType')
    self.charge_type = attributes[:'chargeType']
  end

  if attributes.has_key?(:'invoicingType')
    self.invoicing_type = attributes[:'invoicingType']
  end

  if attributes.has_key?(:'chargeModel')
    self.charge_model = attributes[:'chargeModel']
  end

  if attributes.has_key?(:'upgradeMode')
    self.upgrade_mode = attributes[:'upgradeMode']
  end

  if attributes.has_key?(:'downgradeMode')
    self.downgrade_mode = attributes[:'downgradeMode']
  end

  if attributes.has_key?(:'defaultQuantity')
    self.default_quantity = attributes[:'defaultQuantity']
  end

  if attributes.has_key?(:'minQuantity')
    self.min_quantity = attributes[:'minQuantity']
  end

  if attributes.has_key?(:'maxQuantity')
    self.max_quantity = attributes[:'maxQuantity']
  end

  if attributes.has_key?(:'validFrom')
    self.valid_from = attributes[:'validFrom']
  end

  if attributes.has_key?(:'validTill')
    self.valid_till = attributes[:'validTill']
  end

  if attributes.has_key?(:'tiers')
    if (value = attributes[:'tiers']).is_a?(Array)
      self.tiers = value
    end
  end

  if attributes.has_key?(:'unitOfMeasure')
    self.unit_of_measure = attributes[:'unitOfMeasure']
  end

end
swagger_types() click to toggle source

Attribute type mapping.

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 147
def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'updated' => :'DateTime',
    :'type' => :'String',
    :'version_id' => :'String',
    :'crm_id' => :'String',
    :'id' => :'String',
    :'product_rate_plan_id' => :'String',
    :'unit_of_measure_id' => :'String',
    :'organization_id' => :'String',
    :'name' => :'String',
    :'public_name' => :'String',
    :'description' => :'String',
    :'charge_type' => :'String',
    :'invoicing_type' => :'String',
    :'charge_model' => :'String',
    :'upgrade_mode' => :'String',
    :'downgrade_mode' => :'String',
    :'default_quantity' => :'Integer',
    :'min_quantity' => :'Integer',
    :'max_quantity' => :'Integer',
    :'valid_from' => :'DateTime',
    :'valid_till' => :'DateTime',
    :'tiers' => :'Array<PricingComponentTier>',
    :'unit_of_measure' => :'UnitOfMeasure'
  }
end

Public Instance Methods

==(o) click to toggle source

Checks equality by comparing each attribute. @param [Object] Object to be compared

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 431
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      updated == o.updated &&
      type == o.type &&
      version_id == o.version_id &&
      crm_id == o.crm_id &&
      id == o.id &&
      product_rate_plan_id == o.product_rate_plan_id &&
      unit_of_measure_id == o.unit_of_measure_id &&
      organization_id == o.organization_id &&
      name == o.name &&
      public_name == o.public_name &&
      description == o.description &&
      charge_type == o.charge_type &&
      invoicing_type == o.invoicing_type &&
      charge_model == o.charge_model &&
      upgrade_mode == o.upgrade_mode &&
      downgrade_mode == o.downgrade_mode &&
      default_quantity == o.default_quantity &&
      min_quantity == o.min_quantity &&
      max_quantity == o.max_quantity &&
      valid_from == o.valid_from &&
      valid_till == o.valid_till &&
      tiers == o.tiers &&
      unit_of_measure == o.unit_of_measure
end
_deserialize(type, value) click to toggle source

Deserializes the data based on type @param string type Data type @param string value Value to be deserialized @return [Object] Deserialized data

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 497
def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.parse(value)
  when :Date
    Date.parse(value)
  when :String
    value.to_s
  when :Integer
    value.to_i
  when :Float
    value.to_f
  when :BOOLEAN
    if value.to_s =~ /\A(true|t|yes|y|1)\z/i
      true
    else
      false
    end
  when :Object
    # generic object (usually a Hash), return directly
    value
  when /\AArray<(?<inner_type>.+)>\z/
    inner_type = Regexp.last_match[:inner_type]
    value.map { |v| _deserialize(inner_type, v) }
  when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
    k_type = Regexp.last_match[:k_type]
    v_type = Regexp.last_match[:v_type]
    {}.tap do |hash|
      value.each do |k, v|
        hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
      end
    end
  else # model
    temp_model = Bfwd.const_get(type).new
    temp_model.build_from_hash(value)
  end
end
_to_hash(value) click to toggle source

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value @param [Object] value Any valid value @return [Hash] Returns the value in the form of hash

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 563
def _to_hash(value)
  if value.is_a?(Array)
    value.compact.map{ |v| _to_hash(v) }
  elsif value.is_a?(Hash)
    {}.tap do |hash|
      value.each { |k, v| hash[k] = _to_hash(v) }
    end
  elsif value.respond_to? :to_hash
    value.to_hash
  else
    value
  end
end
build_from_hash(attributes) click to toggle source

Builds the object from hash @param [Hash] attributes Model attributes in the form of hash @return [Object] Returns the model itself

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 476
def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.swagger_types.each_pair do |key, type|
    if type =~ /\AArray<(.*)>/i
      # check to ensure the input is an array given that the the attribute
      # is documented as an array but the input is not
      if attributes[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map{ |v| _deserialize($1, v) } )
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    end # or else data not found in attributes(hash), not an issue as the data can be optional
  end

  self
end
charge_model=(charge_model) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] charge_model Object to be assigned

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 401
def charge_model=(charge_model)
  validator = EnumAttributeValidator.new('String', ["flat", "tiered", "tiered_volume"])
  unless validator.valid?(charge_model)
    fail ArgumentError, "invalid value for 'charge_model', must be one of #{validator.allowable_values}."
  end
  @charge_model = charge_model
end
charge_type=(charge_type) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] charge_type Object to be assigned

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 381
def charge_type=(charge_type)
  validator = EnumAttributeValidator.new('String', ["setup", "subscription", "arrears", "usage"])
  unless validator.valid?(charge_type)
    fail ArgumentError, "invalid value for 'charge_type', must be one of #{validator.allowable_values}."
  end
  @charge_type = charge_type
end
downgrade_mode=(downgrade_mode) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] downgrade_mode Object to be assigned

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 421
def downgrade_mode=(downgrade_mode)
  validator = EnumAttributeValidator.new('String', ["immediate", "delayed"])
  unless validator.valid?(downgrade_mode)
    fail ArgumentError, "invalid value for 'downgrade_mode', must be one of #{validator.allowable_values}."
  end
  @downgrade_mode = downgrade_mode
end
eql?(o) click to toggle source

@see the `==` method @param [Object] Object to be compared

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 463
def eql?(o)
  self == o
end
hash() click to toggle source

Calculates hash code according to all attributes. @return [Fixnum] Hash code

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 469
def hash
  [created, changed_by, updated, type, version_id, crm_id, id, product_rate_plan_id, unit_of_measure_id, organization_id, name, public_name, description, charge_type, invoicing_type, charge_model, upgrade_mode, downgrade_mode, default_quantity, min_quantity, max_quantity, valid_from, valid_till, tiers, unit_of_measure].hash
end
invoicing_type=(invoicing_type) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] invoicing_type Object to be assigned

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 391
def invoicing_type=(invoicing_type)
  validator = EnumAttributeValidator.new('String', ["Immediate", "Aggregated"])
  unless validator.valid?(invoicing_type)
    fail ArgumentError, "invalid value for 'invoicing_type', must be one of #{validator.allowable_values}."
  end
  @invoicing_type = invoicing_type
end
list_invalid_properties() click to toggle source

Show invalid properties with the reasons. Usually used together with valid? @return Array for valid properies with the reasons

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 291
def list_invalid_properties
  invalid_properties = Array.new
  if @type.nil?
    invalid_properties.push("invalid value for 'type', type cannot be nil.")
  end

  if @version_id.nil?
    invalid_properties.push("invalid value for 'version_id', version_id cannot be nil.")
  end

  if @id.nil?
    invalid_properties.push("invalid value for 'id', id cannot be nil.")
  end

  if @product_rate_plan_id.nil?
    invalid_properties.push("invalid value for 'product_rate_plan_id', product_rate_plan_id cannot be nil.")
  end

  if @unit_of_measure_id.nil?
    invalid_properties.push("invalid value for 'unit_of_measure_id', unit_of_measure_id cannot be nil.")
  end

  if @organization_id.nil?
    invalid_properties.push("invalid value for 'organization_id', organization_id cannot be nil.")
  end

  if @name.nil?
    invalid_properties.push("invalid value for 'name', name cannot be nil.")
  end

  if @charge_type.nil?
    invalid_properties.push("invalid value for 'charge_type', charge_type cannot be nil.")
  end

  if @charge_model.nil?
    invalid_properties.push("invalid value for 'charge_model', charge_model cannot be nil.")
  end

  if @default_quantity.nil?
    invalid_properties.push("invalid value for 'default_quantity', default_quantity cannot be nil.")
  end

  if @valid_from.nil?
    invalid_properties.push("invalid value for 'valid_from', valid_from cannot be nil.")
  end

  return invalid_properties
end
to_body() click to toggle source

to_body is an alias to to_hash (backward compatibility) @return [Hash] Returns the object in the form of hash

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 543
def to_body
  to_hash
end
to_hash() click to toggle source

Returns the object in the form of hash @return [Hash] Returns the object in the form of hash

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 549
def to_hash
  hash = {}
  self.class.attribute_map.each_pair do |attr, param|
    value = self.send(attr)
    next if value.nil?
    hash[param] = _to_hash(value)
  end
  hash
end
to_s() click to toggle source

Returns the string representation of the object @return [String] String presentation of the object

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 537
def to_s
  to_hash.to_s
end
type=(type) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] type Object to be assigned

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 371
def type=(type)
  validator = EnumAttributeValidator.new('String', ["tieredPricingComponent", "flatPricingComponent", "tieredVolumePricingComponent"])
  unless validator.valid?(type)
    fail ArgumentError, "invalid value for 'type', must be one of #{validator.allowable_values}."
  end
  @type = type
end
upgrade_mode=(upgrade_mode) click to toggle source

Custom attribute writer method checking allowed values (enum). @param [Object] upgrade_mode Object to be assigned

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 411
def upgrade_mode=(upgrade_mode)
  validator = EnumAttributeValidator.new('String', ["immediate", "delayed"])
  unless validator.valid?(upgrade_mode)
    fail ArgumentError, "invalid value for 'upgrade_mode', must be one of #{validator.allowable_values}."
  end
  @upgrade_mode = upgrade_mode
end
valid?() click to toggle source

Check to see if the all the properties in the model are valid @return true if the model is valid

# File lib/bf_ruby2/models/tiered_pricing_component.rb, line 342
def valid?
  return false if @type.nil?
  type_validator = EnumAttributeValidator.new('String', ["tieredPricingComponent", "flatPricingComponent", "tieredVolumePricingComponent"])
  return false unless type_validator.valid?(@type)
  return false if @version_id.nil?
  return false if @id.nil?
  return false if @product_rate_plan_id.nil?
  return false if @unit_of_measure_id.nil?
  return false if @organization_id.nil?
  return false if @name.nil?
  return false if @charge_type.nil?
  charge_type_validator = EnumAttributeValidator.new('String', ["setup", "subscription", "arrears", "usage"])
  return false unless charge_type_validator.valid?(@charge_type)
  invoicing_type_validator = EnumAttributeValidator.new('String', ["Immediate", "Aggregated"])
  return false unless invoicing_type_validator.valid?(@invoicing_type)
  return false if @charge_model.nil?
  charge_model_validator = EnumAttributeValidator.new('String', ["flat", "tiered", "tiered_volume"])
  return false unless charge_model_validator.valid?(@charge_model)
  upgrade_mode_validator = EnumAttributeValidator.new('String', ["immediate", "delayed"])
  return false unless upgrade_mode_validator.valid?(@upgrade_mode)
  downgrade_mode_validator = EnumAttributeValidator.new('String', ["immediate", "delayed"])
  return false unless downgrade_mode_validator.valid?(@downgrade_mode)
  return false if @default_quantity.nil?
  return false if @valid_from.nil?
  return true
end