class Bfwd::Product

Product

Attributes

account_id[RW]

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

changed_by[RW]

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

created[RW]

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

crm_id[RW]

{"description":"Customer-relationship-management ID of the product.","verbs":}

deleted[RW]
description[RW]

{"description":"A description — for your benefit — of the product. For example: you could explain what service this product entitles a customer to.","verbs":}

duration[RW]

{"description":"Number of length-measures which constitute the product's period.","verbs":}

duration_period[RW]

{"description":"Measure describing the magnitude of the product's period.","verbs":}

id[RW]

{"description":"ID uniquely identifying this product.","verbs":}

metadata[RW]
name[RW]

{"description":"A unique name — for your benefit — used to identify this product within BillForward. It should reflect the fact that this product confers some service to a customer (e.g. \"Gold membership\").
The product can also be defined by the frequency with which it recurs (e.g. \"Monthly Gold membership\").
Remember also that rate plans can override the timing prescribed by their product. If you intend to override that timing, you may consider the product's period duration to be an unimportant factor when it comes to naming it.","verbs":}

payment_terms[RW]
product_type[RW]

{"default":"recurring","description":"The frequency of the product — either recurring or non-recurring.","verbs":}

public_name[RW]

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

start_date[RW]

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

trial[RW]

{"default":0,"description":"Number of trial-length-measures which constitute the product's trial period","verbs":}

trial_period[RW]

{"default":"none","description":"Measure describing the magnitude of the product's trial period.","verbs":}

updated[RW]

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

Public Class Methods

attribute_map() click to toggle source

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

# File lib/bf_ruby2/models/product.rb, line 93
def self.attribute_map
  {
    :'created' => :'created',
    :'changed_by' => :'changedBy',
    :'updated' => :'updated',
    :'id' => :'id',
    :'crm_id' => :'crmID',
    :'account_id' => :'accountID',
    :'name' => :'name',
    :'public_name' => :'publicName',
    :'description' => :'description',
    :'duration' => :'duration',
    :'duration_period' => :'durationPeriod',
    :'metadata' => :'metadata',
    :'trial' => :'trial',
    :'trial_period' => :'trialPeriod',
    :'product_type' => :'productType',
    :'deleted' => :'deleted',
    :'start_date' => :'startDate',
    :'payment_terms' => :'paymentTerms'
  }
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/product.rb, line 142
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?(:'id')
    self.id = attributes[:'id']
  end

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

  if attributes.has_key?(:'accountID')
    self.account_id = attributes[:'accountID']
  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?(:'duration')
    self.duration = attributes[:'duration']
  end

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

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

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

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

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

  if attributes.has_key?(:'deleted')
    self.deleted = attributes[:'deleted']
  else
    self.deleted = false
  end

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

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

end
swagger_types() click to toggle source

Attribute type mapping.

# File lib/bf_ruby2/models/product.rb, line 117
def self.swagger_types
  {
    :'created' => :'DateTime',
    :'changed_by' => :'String',
    :'updated' => :'DateTime',
    :'id' => :'String',
    :'crm_id' => :'String',
    :'account_id' => :'String',
    :'name' => :'String',
    :'public_name' => :'String',
    :'description' => :'String',
    :'duration' => :'Integer',
    :'duration_period' => :'String',
    :'metadata' => :'DynamicMetadata',
    :'trial' => :'Integer',
    :'trial_period' => :'String',
    :'product_type' => :'String',
    :'deleted' => :'BOOLEAN',
    :'start_date' => :'DateTime',
    :'payment_terms' => :'Integer'
  }
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/product.rb, line 315
def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      created == o.created &&
      changed_by == o.changed_by &&
      updated == o.updated &&
      id == o.id &&
      crm_id == o.crm_id &&
      account_id == o.account_id &&
      name == o.name &&
      public_name == o.public_name &&
      description == o.description &&
      duration == o.duration &&
      duration_period == o.duration_period &&
      metadata == o.metadata &&
      trial == o.trial &&
      trial_period == o.trial_period &&
      product_type == o.product_type &&
      deleted == o.deleted &&
      start_date == o.start_date &&
      payment_terms == o.payment_terms
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/product.rb, line 374
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/product.rb, line 440
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/product.rb, line 353
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
duration_period=(duration_period) click to toggle source

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

# File lib/bf_ruby2/models/product.rb, line 285
def duration_period=(duration_period)
  validator = EnumAttributeValidator.new('String', ["minutes", "days", "months", "years"])
  unless validator.valid?(duration_period)
    fail ArgumentError, "invalid value for 'duration_period', must be one of #{validator.allowable_values}."
  end
  @duration_period = duration_period
end
eql?(o) click to toggle source

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

# File lib/bf_ruby2/models/product.rb, line 340
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/product.rb, line 346
def hash
  [created, changed_by, updated, id, crm_id, account_id, name, public_name, description, duration, duration_period, metadata, trial, trial_period, product_type, deleted, start_date, payment_terms].hash
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/product.rb, line 226
def list_invalid_properties
  invalid_properties = Array.new
  if @name.nil?
    invalid_properties.push("invalid value for 'name', name cannot be nil.")
  end

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

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

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

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

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

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

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

  return invalid_properties
end
product_type=(product_type) click to toggle source

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

# File lib/bf_ruby2/models/product.rb, line 305
def product_type=(product_type)
  validator = EnumAttributeValidator.new('String', ["nonrecurring", "recurring"])
  unless validator.valid?(product_type)
    fail ArgumentError, "invalid value for 'product_type', must be one of #{validator.allowable_values}."
  end
  @product_type = product_type
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/product.rb, line 420
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/product.rb, line 426
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/product.rb, line 414
def to_s
  to_hash.to_s
end
trial_period=(trial_period) click to toggle source

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

# File lib/bf_ruby2/models/product.rb, line 295
def trial_period=(trial_period)
  validator = EnumAttributeValidator.new('String', ["none", "minutes", "days", "months"])
  unless validator.valid?(trial_period)
    fail ArgumentError, "invalid value for 'trial_period', must be one of #{validator.allowable_values}."
  end
  @trial_period = trial_period
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/product.rb, line 265
def valid?
  return false if @name.nil?
  return false if @description.nil?
  return false if @duration.nil?
  return false if @duration_period.nil?
  duration_period_validator = EnumAttributeValidator.new('String', ["minutes", "days", "months", "years"])
  return false unless duration_period_validator.valid?(@duration_period)
  return false if @trial.nil?
  return false if @trial_period.nil?
  trial_period_validator = EnumAttributeValidator.new('String', ["none", "minutes", "days", "months"])
  return false unless trial_period_validator.valid?(@trial_period)
  return false if @product_type.nil?
  product_type_validator = EnumAttributeValidator.new('String', ["nonrecurring", "recurring"])
  return false unless product_type_validator.valid?(@product_type)
  return false if @deleted.nil?
  return true
end