Skip to content

Instantly share code, notes, and snippets.

@ashikajith
Created April 25, 2019 14:40
Show Gist options
  • Select an option

  • Save ashikajith/d1f06793956e6d4f38cdb15fb69aa632 to your computer and use it in GitHub Desktop.

Select an option

Save ashikajith/d1f06793956e6d4f38cdb15fb69aa632 to your computer and use it in GitHub Desktop.

Revisions

  1. ashikajith renamed this gist Apr 25, 2019. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. ashikajith created this gist Apr 25, 2019.
    28 changes: 28 additions & 0 deletions rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    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