Class: AdvancedBilling::ListPrepaymentsFilter

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

Overview

ListPrepaymentsFilter Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(date_field: SKIP, start_date: SKIP, end_date: SKIP, additional_properties: {}) ⇒ ListPrepaymentsFilter

Returns a new instance of ListPrepaymentsFilter.



55
56
57
58
59
60
61
62
63
64
65
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 55

def initialize(date_field: SKIP, start_date: SKIP, end_date: SKIP,
               additional_properties: {})
  @date_field = date_field unless date_field == SKIP
  @start_date = start_date unless start_date == SKIP
  @end_date = end_date unless end_date == SKIP

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

Instance Attribute Details

#date_fieldListPrepaymentDateField

The type of filter you would like to apply to your search. ‘created_at` - Time when prepayment was created. `application_at` - Time when prepayment was applied to invoice. Use in query `filter=created_at`.



16
17
18
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 16

def date_field
  @date_field
end

#end_dateDate

The end date (format YYYY-MM-DD) with which to filter the date_field. Returns prepayments with a timestamp up to and including 11:59:59PM in your site’s time zone on the date specified. Use in query: ‘filter=2011-12-15`.

Returns:

  • (Date)


30
31
32
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 30

def end_date
  @end_date
end

#start_dateDate

The start date (format YYYY-MM-DD) with which to filter the date_field. Returns prepayments with a timestamp at or after midnight (12:00:00 AM) in your site’s time zone on the date specified. Use in query: ‘filter=2011-12-15`.

Returns:

  • (Date)


23
24
25
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 23

def start_date
  @start_date
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 68

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  date_field = hash.key?('date_field') ? hash['date_field'] : SKIP
  start_date = hash.key?('start_date') ? hash['start_date'] : SKIP
  end_date = hash.key?('end_date') ? hash['end_date'] : SKIP

  # Clean out expected properties from Hash.
  names.each_value { |k| hash.delete(k) }

  # Create object from extracted values.
  ListPrepaymentsFilter.new(date_field: date_field,
                            start_date: start_date,
                            end_date: end_date,
                            additional_properties: hash)
end

.namesObject

A mapping from model property names to API property names.



33
34
35
36
37
38
39
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 33

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['date_field'] = 'date_field'
  @_hash['start_date'] = 'start_date'
  @_hash['end_date'] = 'end_date'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 51

def self.nullables
  []
end

.optionalsObject

An array for optional fields



42
43
44
45
46
47
48
# File 'lib/advanced_billing/models/list_prepayments_filter.rb', line 42

def self.optionals
  %w[
    date_field
    start_date
    end_date
  ]
end