Class: CreditDevice::Company

Inherits:
Object
  • Object
show all
Defined in:
lib/credit_device/company.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(term, country, page = 1, **parameter) ⇒ Company



5
6
7
8
9
10
# File 'lib/credit_device/company.rb', line 5

def initialize(term, country, page = 1, **parameter)
  @term = term
  @country = country
  @page = page
  @type = parameter[:type] ? set_type(parameter[:type]) : CreditDevice::Type::QueryParameterType::DEFAULT
end

Instance Attribute Details

#countryObject (readonly)

Returns the value of attribute country.



3
4
5
# File 'lib/credit_device/company.rb', line 3

def country
  @country
end

#pageObject (readonly)

Returns the value of attribute page.



3
4
5
# File 'lib/credit_device/company.rb', line 3

def page
  @page
end

#termObject (readonly)

Returns the value of attribute term.



3
4
5
# File 'lib/credit_device/company.rb', line 3

def term
  @term
end

Instance Method Details

#get_allObject



12
13
14
# File 'lib/credit_device/company.rb', line 12

def get_all
  CreditDevice::Client.new(:get, path).request
end

#pathObject



16
17
18
# File 'lib/credit_device/company.rb', line 16

def path
  "companies?#{@type}=#{@term}&country=#{@country}&page=#{@page}"
end

#set_type(type) ⇒ Object



20
21
22
23
# File 'lib/credit_device/company.rb', line 20

def set_type(type)
  raise "type invalid, parameters are: #{CreditDevice::Type::QueryParameterType::QUERY_TYPES.join(',')}" unless CreditDevice::Type::QueryParameterType::QUERY_TYPES.include? type
  type
end