diff --git a/lib/ioki/apis/operator_api.rb b/lib/ioki/apis/operator_api.rb index 12696bbf..f28154a1 100644 --- a/lib/ioki/apis/operator_api.rb +++ b/lib/ioki/apis/operator_api.rb @@ -637,6 +637,13 @@ class OperatorApi path: 'details', model_class: Ioki::Model::Operator::GeocodingSearchDetails ), + Endpoints::Create.new( + :geocoding_reverse_search, + base_path: [API_BASE_PATH, 'geocoding', 'products', :id], + path: 'reverse_search', + model_class: Ioki::Model::Operator::GeocodingReverseSearchResults, + outgoing_model_class: Ioki::Model::Operator::GeocodingReverseSearch + ), Endpoints::Index.new( :no_shows, base_path: [API_BASE_PATH, 'products', :id], diff --git a/lib/ioki/model/operator/geocoding_reverse_search.rb b/lib/ioki/model/operator/geocoding_reverse_search.rb new file mode 100644 index 00000000..6fbc00e1 --- /dev/null +++ b/lib/ioki/model/operator/geocoding_reverse_search.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + class GeocodingReverseSearch < Base + attribute :lat, + on: :create, + type: :float + + attribute :lng, + on: :create, + type: :float + end + end + end +end diff --git a/lib/ioki/model/operator/geocoding_reverse_search_result.rb b/lib/ioki/model/operator/geocoding_reverse_search_result.rb new file mode 100644 index 00000000..5b5fa9ea --- /dev/null +++ b/lib/ioki/model/operator/geocoding_reverse_search_result.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + class GeocodingReverseSearchResult < Base + attribute :type, + on: :read, + type: :string + + attribute :id, + on: :read, + type: :string + + attribute :vendor_id, + on: :read, + type: :string + + attribute :vendor, + on: :read, + type: :string + + attribute :vendor_type, + on: :read, + type: :string + + attribute :location_name, + on: :read, + type: :string + + attribute :formatted_address, + on: :read, + type: :string + + attribute :street_name, + on: :read, + type: :string + + attribute :street_number, + on: :read, + type: :string + + attribute :postal_code, + on: :read, + type: :string + + attribute :city, + on: :read, + type: :string + + attribute :county, + on: :read, + type: :string + + attribute :country, + on: :read, + type: :string + + attribute :lat, + on: :read, + type: :float + + attribute :lng, + on: :read, + type: :float + + attribute :result_type, + on: :read, + type: :string + end + end + end +end diff --git a/lib/ioki/model/operator/geocoding_reverse_search_results.rb b/lib/ioki/model/operator/geocoding_reverse_search_results.rb new file mode 100644 index 00000000..d2fbf67f --- /dev/null +++ b/lib/ioki/model/operator/geocoding_reverse_search_results.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Ioki + module Model + module Operator + class GeocodingReverseSearchResults < Base + attribute :type, + on: :read, + type: :string + + attribute :results, + on: :read, + type: :array, + class_name: 'Ioki::Model::Operator::GeocodingReverseSearchResult' + end + end + end +end diff --git a/spec/ioki/operator_api_spec.rb b/spec/ioki/operator_api_spec.rb index 88fed4dd..392f4000 100644 --- a/spec/ioki/operator_api_spec.rb +++ b/spec/ioki/operator_api_spec.rb @@ -2870,6 +2870,21 @@ end end + describe '#create_geocoding_reverse_search(id)' do + let(:geocoding_search) { Ioki::Model::Operator::GeocodingReverseSearch.new } + + it 'calls request on the client with expected params' do + expect(operator_client).to receive(:request) do |params| + expect(params[:url].to_s).to eq('operator/geocoding/products/0815/reverse_search') + expect(params[:method]).to eq(:post) + [result_with_data, full_response] + end + + expect(operator_client.create_geocoding_reverse_search('0815', geocoding_search, options)) + .to be_a(Ioki::Model::Operator::GeocodingReverseSearchResults) + end + end + describe '#no_show_acknowledge(product_id, no_show_id)' do it 'calls request on the client with expected params' do expect(operator_client).to receive(:request) do |params|