# frozen_string_literal: true require 'codat/base_model' module Codat module Models # Companies for a given company. class Company < BaseModel ENDPOINT = '/companies' attributes :id, :name, :platform, :redirect, :status, :last_sync, :data_connections attributes :integration_id, :source_id, :platform_name, :link_url def self.all(params = {}) result = get(ENDPOINT, params) return [] if result.status == 404 return result.body if result.status == 400 result.body[:results].map { |company| new(json: company) } end def self.create(params = {}) url = format_url(ENDPOINT, {}) result = post(url, params) return { error: 'An error occured.' } if result.status == 404 || result.status == 400 new(json: result.body) end end end end