Sha256: 9fffe5fcc073719384a24fa49abea8527e6dd59e30b2cfe025506a7ef9883dcf

Contents?: true

Size: 624 Bytes

Versions: 1

Compression:

Stored size: 624 Bytes

Contents

module SkinbaronApiClient
  module Endpoints
    class Search
      attr_reader :skinbaron_client

      def initialize(skinbaron_client)
        @skinbaron_client = skinbaron_client
      end

      def call(item:)
        body = @skinbaron_client.config.base_body.merge({ "search_item": item })
        response = @skinbaron_client.http_client.post(endpoint: "Search", body: body)

        return nil unless response[:status].success?

        JSON.parse(response[:body])
      rescue JSON::ParserError => e
        logger.error("Failed to parse search response", error: e.message)
        nil
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
skinbaron_api_client-0.1.0 lib/skinbaron_api_client/endpoints/search.rb