Class: Gusto::FlowsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/fern_gusto/flows/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Gusto::FlowsClient

Parameters:



16
17
18
# File 'lib/fern_gusto/flows/client.rb', line 16

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientGusto::RequestClient (readonly)



11
12
13
# File 'lib/fern_gusto/flows/client.rb', line 11

def request_client
  @request_client
end

Instance Method Details

#create(company_uuid:, flow_type:, entity_uuid: nil, entity_type: nil, request_options: nil) ⇒ Object

api.flows.create(company_uuid: “company_uuid”, flow_type: “company_onboarding”)



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fern_gusto/flows/client.rb', line 39

def create(company_uuid:, flow_type:, entity_uuid: nil, entity_type: nil, request_options: nil)
  response = @request_client.conn.post do | req |
  unless request_options&.timeout_in_seconds.nil?
req.options.timeout = request_options.timeout_in_seconds
  end
  unless request_options&.token.nil?
req.headers["Authorization"] = request_options.token
  end
  unless request_options&.gusto_api_version.nil?
req.headers["X-Gusto-API-Version"] = request_options.gusto_api_version
  end
  req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact
  unless request_options.nil? || request_options&.additional_query_parameters.nil?
req.params = { **(request_options&.additional_query_parameters || {}) }.compact
  end
  req.body = { **(request_options&.additional_body_parameters || {}), flow_type: flow_type, entity_uuid: entity_uuid, entity_type: entity_type }.compact
  req.url "#{@request_client.get_url(request_options: request_options)}/v1/companies/#{company_uuid}/flows"
end
  Gusto::Flows::Flow.from_json(json_object: response.body)
end