Sha256: 0dd052f9f1c31814973e246e886ac0c599533a70c4f288ac8bbb997d65a992f0
Contents?: true
Size: 1.18 KB
Versions: 3
Compression:
Stored size: 1.18 KB
Contents
# frozen_string_literal: true require 'codat/base_model' module Codat module Models # Companies for a given company. class Company < BaseModel ENDPOINTS = { collection: '/companies', single: '/companies/:company_id' }.freeze attributes :id, :name, :platform, :redirect, :status, :last_sync, :data_connections attributes :integration_id, :source_id, :platform_name, :link_url # Returns the list of companies in the Codat account. def self.all(params = {}) result = get(ENDPOINTS[:collection], params) return [] if result.status == 404 return result.body if result.status == 400 result.body[:results].map { |company| new(json: company) } end def self.find(company_id) url = format_url(ENDPOINTS[:single], company_id: company_id) result = get(url) return nil if result.status == 404 new(json: result.body) end def self.create(params = {}) result = post(ENDPOINTS[:collection], params) return { error: 'An error occured.' } if result.status == 404 || result.status == 400 new(json: result.body) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
codat-0.1.4 | lib/codat/models/company.rb |
codat-0.1.3 | lib/codat/models/company.rb |
codat-0.1.2 | lib/codat/models/company.rb |