Module: Legion::Extensions::ServiceNow::Currency::Runners::Currency
Instance Method Summary
collapse
#connection, #fetch_oauth2_token, #handle_response
Instance Method Details
#get_currency(sys_id:) ⇒ Object
17
18
19
20
|
# File 'lib/legion/extensions/service_now/currency/runners/currency.rb', line 17
def get_currency(sys_id:, **)
resp = connection(**).get("/api/now/table/fx_currency/#{sys_id}")
{ currency: resp.body['result'] }
end
|
#list_currencies(sysparm_limit: 100, sysparm_offset: 0) ⇒ Object
11
12
13
14
15
|
# File 'lib/legion/extensions/service_now/currency/runners/currency.rb', line 11
def list_currencies(sysparm_limit: 100, sysparm_offset: 0, **)
params = { sysparm_limit: sysparm_limit, sysparm_offset: sysparm_offset }
resp = connection(**).get('/api/now/table/fx_currency', params)
{ currencies: resp.body['result'] }
end
|
#list_exchange_rates(from_currency: nil, to_currency: nil, sysparm_limit: 100) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/legion/extensions/service_now/currency/runners/currency.rb', line 22
def list_exchange_rates(from_currency: nil, to_currency: nil,
sysparm_limit: 100, **)
params = { sysparm_limit: sysparm_limit }
query_parts = []
query_parts << "from_cur=#{from_currency}" if from_currency
query_parts << "to_cur=#{to_currency}" if to_currency
params[:sysparm_query] = query_parts.join('^') unless query_parts.empty?
resp = connection(**).get('/api/now/table/fx_rate', params)
{ exchange_rates: resp.body['result'] }
end
|