Created
April 25, 2019 14:40
-
-
Save ashikajith/d1f06793956e6d4f38cdb15fb69aa632 to your computer and use it in GitHub Desktop.
Api Call Wrapper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Ubiquity | |
class ImporterClient | |
include HTTParty | |
format :json | |
base_uri 'https://importer.repo-test.ubiquity.press' | |
attr_accessor :file_url_hash, :code, :file_name_hash | |
def initialize(response) | |
if response | |
@file_name_hash = Hash[response['works'].map { |ele| [ele['uuid'], ele['name']] }] | |
@file_url_hash = Hash[response['works'].map { |ele| [ele['uuid'], ele['providers']['S3Storage']['link']] }] | |
else | |
@file_name_hash = {} | |
@file_url_hash = {} | |
end | |
end | |
def self.get_s3_url(uuid) | |
response = get("/api/entry/#{uuid}", base_uri: base_uri) | |
if response.success? | |
new(response) | |
else | |
new(nil) | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment