Sha256: 1cb2a401e632940b601511c62bc57c4fb693c8d2d4c8a4884c53d1ca6c6a68c3
Contents?: true
Size: 1.96 KB
Versions: 5
Compression:
Stored size: 1.96 KB
Contents
require 'faraday' require 'json' require 'search_kit/thor' require 'thor' module SearchKit module CLI class Documents < Thor namespace :documents no_commands do def client @client ||= SearchKit::Clients::Documents.new end def messages @messages ||= SearchKit::Messages.new end end document :create def create(slug, document) document = JSON.parse(document, symbolize_names: true) response = client.create(slug, document) messages.info response.to_json rescue Errors::IndexNotFound messages.not_found rescue Errors::BadRequest messages.bad_request rescue Errors::Unprocessable messages.unprocessable rescue Faraday::ConnectionFailed messages.no_service rescue JSON::ParserError messages.json_parse_error end document :delete def delete(slug, id) response = client.delete(slug, id) messages.info response.to_json rescue Errors::IndexNotFound messages.not_found rescue Faraday::ConnectionFailed messages.no_service end document :show def show(slug, id) response = client.show(slug, id) messages.info response.to_json rescue Errors::IndexNotFound messages.not_found rescue Faraday::ConnectionFailed messages.no_service end document :update def update(slug, id, document) document = JSON.parse(document, symbolize_names: true) response = client.update(slug, id, document) messages.info response.to_json rescue JSON::ParserError messages.json_parse_error rescue Errors::BadRequest messages.bad_request rescue Errors::IndexNotFound messages.not_found rescue Errors::Unprocessable messages.unprocessable rescue Faraday::ConnectionFailed messages.no_service end end end end
Version data entries
5 entries across 5 versions & 1 rubygems