Skip to content

Instantly share code, notes, and snippets.

@ashikajith
Created April 25, 2019 14:40
Show Gist options
  • Save ashikajith/d1f06793956e6d4f38cdb15fb69aa632 to your computer and use it in GitHub Desktop.
Save ashikajith/d1f06793956e6d4f38cdb15fb69aa632 to your computer and use it in GitHub Desktop.
Api Call Wrapper
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