Sha256: db20d428623d470a96ebdd0e83b9e13098e00d7c8bb16bdd9bf77ca662849805
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 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 [] unless successful_response?(result) result.body[:results].map { |company| new(json: company) } end def self.find(company_id) url = format_url(ENDPOINTS[:single], company_id:) result = get(url) return nil unless successful_response?(result) new(json: result.body) end def self.create(params = {}) result = post(ENDPOINTS[:collection], params) return { error: 'An error occured.' } unless successful_response?(result) new(json: result.body) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
codat-0.1.8 | lib/codat/models/company.rb |
codat-0.1.7 | lib/codat/models/company.rb |