Module: WolfCore::Integrations::ContractApiOperations
- Includes:
- HttpOperations
- Defined in:
- lib/wolf_core/application/integrations/contract_api_operations.rb
Constant Summary
collapse
- CONTRACT_ID_REGEX =
/.*-(\d+)-(\d+)/
Instance Method Summary
collapse
-
#fetch_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, query: nil) ⇒ Object
-
#fetch_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, error_message:, error_data: nil, query: nil) ⇒ Object
-
#update_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:) ⇒ Object
-
#update_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:, error_message:, error_data: nil) ⇒ Object
#async_http_get, #async_http_patch, #async_http_post, #async_http_put, #http_get, #http_patch, #http_post, #http_put, #parse_http_response, #parsed_http_get, #parsed_http_patch, #parsed_http_post, #parsed_http_put, #response_success?, #safe_http_get, #safe_http_patch, #safe_http_post, #safe_http_put, #validate_http_response
#log_object
Methods included from AsyncUtils
#run_async
#raise_service_error
Instance Method Details
#fetch_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, query: nil) ⇒ Object
26
27
28
29
30
31
32
33
34
|
# File 'lib/wolf_core/application/integrations/contract_api_operations.rb', line 26
def fetch_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, query: nil)
order_id, jobseeker_id = (contract_id)
query ||= {}
parsed_http_get(
headers: { "Authorization" => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/contracts/#{order_id}/#{jobseeker_id}",
query: query.merge(tenant: tenant)
)
end
|
#fetch_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, error_message:, error_data: nil, query: nil) ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/wolf_core/application/integrations/contract_api_operations.rb', line 8
def fetch_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, error_message:, error_data: nil, query: nil)
response = fetch_contract(
wolf_token: wolf_token,
tenant: tenant,
wolf_platform_url: wolf_platform_url,
contract_id: contract_id,
query: query
)
order_id, jobseeker_id = (contract_id)
error_data ||= {}
validate_http_response(
response: response,
message: error_message,
error_data: error_data.merge(contract_id: contract_id, order_id: order_id, jobseeker_id: jobseeker_id, query: query)
)
response.body.dig("data", "table", "contract")
end
|
#update_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:) ⇒ Object
54
55
56
57
58
59
60
61
62
|
# File 'lib/wolf_core/application/integrations/contract_api_operations.rb', line 54
def update_contract(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:)
order_id, jobseeker_id = (contract_id)
parsed_http_put(
headers: { "Authorization" => "Bearer #{wolf_token}" },
url: "#{wolf_platform_url}/api/v2/contracts/#{order_id}/#{jobseeker_id}",
query: { tenant: tenant },
body: contract
)
end
|
#update_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:, error_message:, error_data: nil) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/wolf_core/application/integrations/contract_api_operations.rb', line 36
def update_contract!(wolf_token:, tenant:, wolf_platform_url:, contract_id:, contract:, error_message:, error_data: nil)
response = update_contract(
wolf_token: wolf_token,
tenant: tenant,
wolf_platform_url: wolf_platform_url,
contract_id: contract_id,
contract: contract
)
order_id, jobseeker_id = (contract_id)
error_data ||= {}
validate_http_response(
response: response,
message: error_message,
error_data: error_data.merge(contract_id: contract_id, order_id: order_id, jobseeker_id: jobseeker_id, contract: contract)
)
response
end
|