Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump SDK to match Merge API, April 2024 #19

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
101 changes: 101 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
PATH
remote: .
specs:
merge_ruby_client (0.1.0)
async-http-faraday (>= 0.0, < 1.0)
faraday (>= 1.10, < 3.0)
faraday-multipart (>= 0.0, < 2.0)
faraday-net_http (>= 1.0, < 4.0)
faraday-retry (>= 1.0, < 3.0)
mini_mime

GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
async (1.32.1)
console (~> 1.10)
nio4r (~> 2.3)
timers (~> 4.1)
async-http (0.60.2)
async (>= 1.25)
async-io (>= 1.28)
async-pool (>= 0.2)
protocol-http (~> 0.24.0)
protocol-http1 (~> 0.15.0)
protocol-http2 (~> 0.15.0)
traces (>= 0.10.0)
async-http-faraday (0.12.0)
async-http (~> 0.42)
faraday
async-io (1.43.2)
async
async-pool (0.4.0)
async (>= 1.25)
base64 (0.2.0)
console (1.19.0)
fiber-annotation
fiber-local
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (3.0.2)
faraday-retry (2.2.1)
faraday (~> 2.0)
fiber-annotation (0.2.0)
fiber-local (1.0.0)
json (2.7.1)
language_server-protocol (3.17.0.3)
mini_mime (1.1.5)
minitest (5.22.2)
multipart-post (2.4.0)
nio4r (2.7.1)
parallel (1.24.0)
parser (3.3.0.5)
ast (~> 2.4.1)
racc
protocol-hpack (1.4.2)
protocol-http (0.24.7)
protocol-http1 (0.15.1)
protocol-http (~> 0.22)
protocol-http2 (0.15.1)
protocol-hpack (~> 1.4)
protocol-http (~> 0.18)
racc (1.7.3)
rainbow (3.1.1)
rake (13.1.0)
regexp_parser (2.9.0)
rexml (3.2.6)
rubocop (1.60.2)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.30.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
timers (4.3.5)
traces (0.11.1)
unicode-display_width (2.5.0)

PLATFORMS
ruby

DEPENDENCIES
merge_ruby_client!
minitest (~> 5.0)
rake (~> 13.0)
rubocop (~> 1.21)

BUNDLED WITH
2.1.4
90 changes: 63 additions & 27 deletions lib/merge_ruby_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,53 +5,89 @@
require_relative "requests"
require_relative "merge_ruby_client/ats/client"
require_relative "merge_ruby_client/crm/client"
require_relative "merge_ruby_client/ticketing/client"
require_relative "merge_ruby_client/filestorage/client"
require_relative "merge_ruby_client/hris/client"
require_relative "merge_ruby_client/ticketing/client"
require_relative "merge_ruby_client/accounting/client"

module Merge
class Client
attr_reader :ats, :crm, :filestorage, :hris, :ticketing, :accounting
# @return [Merge::Ats::Client]
attr_reader :ats
# @return [Merge::Crm::Client]
attr_reader :crm
# @return [Merge::Ticketing::Client]
attr_reader :ticketing
# @return [Merge::Filestorage::Client]
attr_reader :filestorage
# @return [Merge::Hris::Client]
attr_reader :hris
# @return [Merge::Accounting::Client]
attr_reader :accounting

# @param environment [Environment]
# @param environment [Merge::Environment]
# @param base_url [String]
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
# @param timeout_in_seconds [Long]
# @param api_key [String]
# @param account_token [String] Token identifying the end user.
# @return [Client]
def initialize(api_key:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil,
account_token: nil)
@request_client = RequestClient.new(environment: environment, max_retries: max_retries,
timeout_in_seconds: timeout_in_seconds, api_key: api_key, account_token: account_token)
@ats = Ats::Client.new(request_client: @request_client)
@crm = Crm::Client.new(request_client: @request_client)
@filestorage = Filestorage::Client.new(request_client: @request_client)
@hris = Hris::Client.new(request_client: @request_client)
@ticketing = Ticketing::Client.new(request_client: @request_client)
@accounting = Accounting::Client.new(request_client: @request_client)
# @return [Merge::Client]
def initialize(api_key:, environment: Environment::PRODUCTION, base_url: nil, max_retries: nil,
timeout_in_seconds: nil, account_token: nil)
@request_client = Merge::RequestClient.new(
environment: environment,
base_url: base_url,
max_retries: max_retries,
timeout_in_seconds: timeout_in_seconds,
api_key: api_key,
account_token: account_token
)
@ats = Merge::Ats::Client.new(request_client: @request_client)
@crm = Merge::Crm::Client.new(request_client: @request_client)
@ticketing = Merge::Ticketing::Client.new(request_client: @request_client)
@filestorage = Merge::Filestorage::Client.new(request_client: @request_client)
@hris = Merge::Hris::Client.new(request_client: @request_client)
@accounting = Merge::Accounting::Client.new(request_client: @request_client)
end
end

class AsyncClient
attr_reader :ats, :crm, :filestorage, :hris, :ticketing, :accounting
# @return [Merge::Ats::AsyncClient]
attr_reader :ats
# @return [Merge::Crm::AsyncClient]
attr_reader :crm
# @return [Merge::Ticketing::AsyncClient]
attr_reader :ticketing
# @return [Merge::Filestorage::AsyncClient]
attr_reader :filestorage
# @return [Merge::Hris::AsyncClient]
attr_reader :hris
# @return [Merge::Accounting::AsyncClient]
attr_reader :accounting

# @param environment [Environment]
# @param environment [Merge::Environment]
# @param base_url [String]
# @param max_retries [Long] The number of times to retry a failed request, defaults to 2.
# @param timeout_in_seconds [Long]
# @param api_key [String]
# @param account_token [String] Token identifying the end user.
# @return [AsyncClient]
def initialize(api_key:, environment: Environment::PRODUCTION, max_retries: nil, timeout_in_seconds: nil,
account_token: nil)
@async_request_client = AsyncRequestClient.new(environment: environment, max_retries: max_retries,
timeout_in_seconds: timeout_in_seconds, api_key: api_key, account_token: account_token)
@ats = Ats::AsyncClient.new(request_client: @async_request_client)
@crm = Crm::AsyncClient.new(request_client: @async_request_client)
@filestorage = Filestorage::AsyncClient.new(request_client: @async_request_client)
@hris = Hris::AsyncClient.new(request_client: @async_request_client)
@ticketing = Ticketing::AsyncClient.new(request_client: @async_request_client)
@accounting = Accounting::AsyncClient.new(request_client: @async_request_client)
# @return [Merge::AsyncClient]
def initialize(api_key:, environment: Environment::PRODUCTION, base_url: nil, max_retries: nil,
timeout_in_seconds: nil, account_token: nil)
@async_request_client = Merge::AsyncRequestClient.new(
environment: environment,
base_url: base_url,
max_retries: max_retries,
timeout_in_seconds: timeout_in_seconds,
api_key: api_key,
account_token: account_token
)
@ats = Merge::Ats::AsyncClient.new(request_client: @async_request_client)
@crm = Merge::Crm::AsyncClient.new(request_client: @async_request_client)
@ticketing = Merge::Ticketing::AsyncClient.new(request_client: @async_request_client)
@filestorage = Merge::Filestorage::AsyncClient.new(request_client: @async_request_client)
@hris = Merge::Hris::AsyncClient.new(request_client: @async_request_client)
@accounting = Merge::Accounting::AsyncClient.new(request_client: @async_request_client)
end
end
end
44 changes: 30 additions & 14 deletions lib/merge_ruby_client/accounting/account_details/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,53 +7,69 @@
module Merge
module Accounting
class AccountDetailsClient
# @return [Merge::RequestClient]
attr_reader :request_client

# @param request_client [RequestClient]
# @return [Accounting::AccountDetailsClient]
# @param request_client [Merge::RequestClient]
# @return [Merge::Accounting::AccountDetailsClient]
def initialize(request_client:)
# @type [RequestClient]
@request_client = request_client
end

# Get details for a linked account.
#
# @param request_options [RequestOptions]
# @return [Accounting::AccountDetails]
# @param request_options [Merge::RequestOptions]
# @return [Merge::Accounting::AccountDetails]
# @example
# api = Merge::Client.new(
# environment: Environment::PRODUCTION,
# base_url: "https://api.example.com",
# api_key: "YOUR_AUTH_TOKEN"
# )
# api.accounting.retrieve
def retrieve(request_options: nil)
response = @request_client.conn.get("/api/accounting/v1/account-details") do |req|
response = @request_client.conn.get do |req|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
req.headers["X-Account-Token"] = request_options.account_token unless request_options&.account_token.nil?
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/account-details"
end
Accounting::AccountDetails.from_json(json_object: response.body)
Merge::Accounting::AccountDetails.from_json(json_object: response.body)
end
end

class AsyncAccountDetailsClient
# @return [Merge::AsyncRequestClient]
attr_reader :request_client

# @param request_client [AsyncRequestClient]
# @return [Accounting::AsyncAccountDetailsClient]
# @param request_client [Merge::AsyncRequestClient]
# @return [Merge::Accounting::AsyncAccountDetailsClient]
def initialize(request_client:)
# @type [AsyncRequestClient]
@request_client = request_client
end

# Get details for a linked account.
#
# @param request_options [RequestOptions]
# @return [Accounting::AccountDetails]
# @param request_options [Merge::RequestOptions]
# @return [Merge::Accounting::AccountDetails]
# @example
# api = Merge::Client.new(
# environment: Environment::PRODUCTION,
# base_url: "https://api.example.com",
# api_key: "YOUR_AUTH_TOKEN"
# )
# api.accounting.retrieve
def retrieve(request_options: nil)
Async do
response = @request_client.conn.get("/api/accounting/v1/account-details") do |req|
response = @request_client.conn.get do |req|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
req.headers["X-Account-Token"] = request_options.account_token unless request_options&.account_token.nil?
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/account-details"
end
Accounting::AccountDetails.from_json(json_object: response.body)
Merge::Accounting::AccountDetails.from_json(json_object: response.body)
end
end
end
Expand Down
44 changes: 30 additions & 14 deletions lib/merge_ruby_client/accounting/account_token/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,55 +7,71 @@
module Merge
module Accounting
class AccountTokenClient
# @return [Merge::RequestClient]
attr_reader :request_client

# @param request_client [RequestClient]
# @return [Accounting::AccountTokenClient]
# @param request_client [Merge::RequestClient]
# @return [Merge::Accounting::AccountTokenClient]
def initialize(request_client:)
# @type [RequestClient]
@request_client = request_client
end

# Returns the account token for the end user with the provided public token.
#
# @param public_token [String]
# @param request_options [RequestOptions]
# @return [Accounting::AccountToken]
# @param request_options [Merge::RequestOptions]
# @return [Merge::Accounting::AccountToken]
# @example
# api = Merge::Client.new(
# environment: Environment::PRODUCTION,
# base_url: "https://api.example.com",
# api_key: "YOUR_AUTH_TOKEN"
# )
# api.accounting.retrieve(public_token: "public_token")
def retrieve(public_token:, request_options: nil)
response = @request_client.conn.get("/api/accounting/v1/account-token/#{public_token}") do |req|
response = @request_client.conn.get do |req|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
req.headers["X-Account-Token"] = request_options.account_token unless request_options&.account_token.nil?
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/account-token/#{public_token}"
end
Accounting::AccountToken.from_json(json_object: response.body)
Merge::Accounting::AccountToken.from_json(json_object: response.body)
end
end

class AsyncAccountTokenClient
# @return [Merge::AsyncRequestClient]
attr_reader :request_client

# @param request_client [AsyncRequestClient]
# @return [Accounting::AsyncAccountTokenClient]
# @param request_client [Merge::AsyncRequestClient]
# @return [Merge::Accounting::AsyncAccountTokenClient]
def initialize(request_client:)
# @type [AsyncRequestClient]
@request_client = request_client
end

# Returns the account token for the end user with the provided public token.
#
# @param public_token [String]
# @param request_options [RequestOptions]
# @return [Accounting::AccountToken]
# @param request_options [Merge::RequestOptions]
# @return [Merge::Accounting::AccountToken]
# @example
# api = Merge::Client.new(
# environment: Environment::PRODUCTION,
# base_url: "https://api.example.com",
# api_key: "YOUR_AUTH_TOKEN"
# )
# api.accounting.retrieve(public_token: "public_token")
def retrieve(public_token:, request_options: nil)
Async do
response = @request_client.conn.get("/api/accounting/v1/account-token/#{public_token}") do |req|
response = @request_client.conn.get do |req|
req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
req.headers["X-Account-Token"] = request_options.account_token unless request_options&.account_token.nil?
req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/account-token/#{public_token}"
end
Accounting::AccountToken.from_json(json_object: response.body)
Merge::Accounting::AccountToken.from_json(json_object: response.body)
end
end
end
Expand Down
Loading