Class: Gusto::Companies::AttachmentsClient
- Inherits:
-
Object
- Object
- Gusto::Companies::AttachmentsClient
- Defined in:
- lib/fern_gusto/companies/attachments/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#create(company_id:, document:, category:, request_options: nil) ⇒ Object
api.companies.attachments.create(company_id: “company_id”, document: my_file.txt).
-
#get(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”).
-
#get_download_url(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get_download_url(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”).
- #initialize(request_client:) ⇒ Gusto::Companies::AttachmentsClient constructor
-
#list(company_id:, request_options: nil) ⇒ Object
api.companies.attachments.list(company_id: “company_id”).
Constructor Details
#initialize(request_client:) ⇒ Gusto::Companies::AttachmentsClient
23 24 25 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 23 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Gusto::RequestClient (readonly)
18 19 20 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 18 def request_client @request_client end |
Instance Method Details
#create(company_id:, document:, category:, request_options: nil) ⇒ Object
api.companies.attachments.create(company_id: “company_id”, document: my_file.txt)
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 150 def create(company_id:, document:, category:, request_options: nil) response = @request_client.conn.post do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), document: Gusto::FileUtilities.as_faraday_multipart(file_like: document), category: category }.compact req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/attachments" end Gusto::CompanyAttachment::CompanyAttachment.from_json(json_object: response.body) end |
#get(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”)
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 39 def get(company_id:, company_attachment_uuid:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/attachments/#{}" end Gusto::CompanyAttachment::CompanyAttachment.from_json(json_object: response.body) end |
#get_download_url(company_id:, company_attachment_uuid:, request_options: nil) ⇒ Object
api.companies.attachments.get_download_url(company_id: “company_id”, company_attachment_uuid: “company_attachment_uuid”)
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 74 def get_download_url(company_id:, company_attachment_uuid:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/attachments/#{}/download_url" end Gusto::Companies::Attachments::AttachmentsGetDownloadURLResponse.from_json(json_object: response.body) end |
#list(company_id:, request_options: nil) ⇒ Object
api.companies.attachments.list(company_id: “company_id”)
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/fern_gusto/companies/attachments/client.rb', line 108 def list(company_id:, request_options: nil) response = @request_client.conn.get do | req | unless &.timeout_in_seconds.nil? req..timeout = .timeout_in_seconds end unless &.token.nil? req.headers["Authorization"] = .token end unless &.gusto_api_version.nil? req.headers["X-Gusto-API-Version"] = .gusto_api_version end req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/v1/companies/#{company_id}/attachments" end parsed_json = JSON.parse(response.body) parsed_json&.map do | item | item = item.to_json Gusto::CompanyAttachment::CompanyAttachment.from_json(json_object: item) end end |