class SellsyV2::Company

Constants

ROOT_PATH

Public Class Methods

all(**options) click to toggle source
# File lib/sellsy_v2/company.rb, line 17
def self.all(**options)
  companies_response = Request.new(path: ROOT_PATH, verb: 'get', options: options).call
  if companies_response.success?
    companies_response.data.dig('data').map{Company.new(_1)}
  end
end
find(id, **options) click to toggle source
# File lib/sellsy_v2/company.rb, line 24
def self.find(id, **options)
  company_response = Request.new(path: "#{ROOT_PATH}/#{id}", verb: 'get', options: options).call
  if company_response.success?
    Company.new(company_response.data)
  end
end
new(attr) click to toggle source
# File lib/sellsy_v2/company.rb, line 8
def initialize(attr)
  attr.each do |k,v|
    define_singleton_method(k) { instance_variable_get("@#{k}") }
    define_singleton_method("#{k}=") { |val| instance_variable_set("@#{k}", val) }

    instance_variable_set("@#{k}", v)
  end
end

Public Instance Methods

addresses(**options) click to toggle source
# File lib/sellsy_v2/company.rb, line 31
def addresses(**options)
  verb = 'get'
  path = "#{ROOT_PATH}/#{id}/addresses"
  company_addresses_response = Request.new(path: path, verb: verb, options: options).call
  if company_addresses_response.success?
    company_addresses_response.data.dig('data').map{Address.new(_1)}
  end
end