Sha256: 137619d21c40f65f61ffc402c90aab898b3e6e85fdbe73df689f4a2715c344c5
Contents?: true
Size: 876 Bytes
Versions: 2
Compression:
Stored size: 876 Bytes
Contents
# frozen_string_literal: true module Omdb module Api class Request BASE_URI = 'https://www.omdbapi.com'.freeze 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
omdb-api-1.3.0 | lib/omdb/api/request.rb |
omdb-api-1.2.0 | lib/omdb/api/request.rb |