class Translator::Smartling::API::FileUris

Public Class Methods

new(project_id:, token:) click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 7
def initialize(project_id:, token:)
  @project_id   = project_id
  @token        = token
end

Public Instance Methods

build_request() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 12
def build_request
  Net::HTTP::Get.new(uri, headers)
end
format_date() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 28
def format_date
  DateTime.parse(1.week.ago.to_s).iso8601.to_s
end
headers() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 16
def headers
  { 'Authorization' => "Bearer #{@token}", 'Content-Type' => 'application/json' }
end
return_value() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 36
def return_value
  @return_value ||= response_body['response']['data']['items'].map { |item| item['fileUri'] }
end
success?() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 32
def success?
  @response.code == '200'
end
to_s() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 40
def to_s
  return_value.join("\n").prepend("\n")
end
uri() click to toggle source
# File lib/nexmo_developer/app/services/translator/smartling/api/file_uris.rb, line 20
def uri
  @uri ||= begin
    uri = URI("https://api.smartling.com/published-files-api/v2/projects/#{@project_id}/files/list/recently-published")
    uri.query = URI.encode_www_form({ 'publishedAfter' => format_date })
    uri
  end
end