Class: Gusto::AsyncFlowsClient

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::AsyncFlowsClient

Parameters:



67
68
69
# File 'lib/fern_gusto/flows/client.rb', line 67

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientGusto::AsyncRequestClient (readonly)



62
63
64
# File 'lib/fern_gusto/flows/client.rb', line 62

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”)



90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/fern_gusto/flows/client.rb', line 90

def create(company_uuid:, flow_type:, entity_uuid: nil, entity_type: nil, request_options: nil)
  Async do
    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
end