Sha256: 1b79b766652f477f938cd0c3e3932dee0e50693c741e2d0626a4302747c5bd68
Contents?: true
Size: 869 Bytes
Versions: 3
Compression:
Stored size: 869 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(client, method, value, options) @api_key = client.api_key @value = CGI.escape(value) @options = options @field = if /id/.match?(method) 'i' elsif /title/.match?(method) 't' else 's' end 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
omdb-api-1.4.2 | lib/omdb/api/request.rb |
omdb-api-1.4.1 | lib/omdb/api/request.rb |
omdb-api-1.4.0 | lib/omdb/api/request.rb |