Sha256: b76feab0254b89972520a073bac0089ef45cc4308ce418b93ff919b687843356
Contents?: true
Size: 863 Bytes
Versions: 1
Compression:
Stored size: 863 Bytes
Contents
# frozen_string_literal: true module Omdb module Api class Request BASE_URI = 'https://www.omdbapi.com' attr_reader :api_key, :field, :value, :options def initialize(api_key, method, value, options) @api_key = api_key @field = if /id/.match?(method) 'i' elsif /title/.match?(method) 't' else 's' end @value = CGI.escape(value) @options = options end def query_params { query: { apikey: api_key, field.to_s => value.to_s }.merge(options) } end def response @response ||= HTTParty.get(BASE_URI, query_params) end def success? (response['Response'] || response['root']['response']) == 'True' end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
omdb-api-1.0.0 | lib/omdb/api/request.rb |