10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/localedata/client.rb', line 10
def pull(project_id, locale)
success = false
status_code = 0
yaml_data = nil
error_message = nil
begin
get_data = { access_token: @access_token, project_id: project_id, language_code: locale }
response = connection.get("/api/v1/exports", get_data)
success = response.success?
status_code = response.status
data = JSON.parse(response.body)
yaml_data = data["yaml"]
error_message = data["error"]
rescue Faraday::ConnectionFailed
success = false
error_message = "API connection failed."
rescue JSON::ParserError
success = false
error_message = "API response parsing failed."
end
{ success: success, status_code: status_code, yaml: yaml_data, error: error_message }
end
|