diff --git a/lib/beyond_api/services/shop/location.rb b/lib/beyond_api/services/shop/location.rb new file mode 100644 index 0000000..04bf509 --- /dev/null +++ b/lib/beyond_api/services/shop/location.rb @@ -0,0 +1,123 @@ +# frozen_string_literal: true + +module BeyondApi + module Shop + # @example How to instantiate a client + # @client = BeyondApi::Shop::Location.new(api_url: 'https://example.com/api', access_token: 'your_token') + class Location < BaseService + # Create a location. + # + # @see https://developer.epages.com/beyond-docs/#create_location + # + # param body [Hash] the request body + # + # return [hash] + # + # @example + # body = { + # "languageCode": "de", + # "storeCode": "MLC-St-Ives", + # "companyName": "My little Cornershop - St.Ives", + # "primaryPhone": "(800) 555-0102", + # "address": { + # "postalCode": "90999", + # "street": "Hudson Way", + # "houseNumber": "27", + # "city": "St.Ives", + # "country": "GB", + # "dependentLocality": "", + # "state": "Cornwall" + # }, + # "googleStatus": "ACTIVE", + # "googlePrimaryCategory": { + # "categoryId": "gcid:storefood", + # "displayName": "Food" + # }, + # "googleAdditionalCategories": [ { + # "displayName": "Drinks", + # "categoryId": "gcid:storedrinks" + # } ], + # "regularHours": { + # "periods": [ { + # "openDay": "MONDAY", + # "openTime": "08:00", + # "closeDay": "MONDAY", + # "closeTime": "17:00" + # }, { + # "openDay": "SATURDAY", + # "openTime": "10:00", + # "closeDay": "SATURDAY", + # "closeTime": "16:00" + # } ] + # }, + # "latLng": { + # "latitude": 53.5847424, + # "longitude": 9.968901 + # } + # } + # @client.create(body) + def create(body) + post('shop/locations', body) + end + + # Retrieve a list of all locations for the current shop + # + # @see https://developer.epages.com/beyond-docs/#list_locations + # + # @option params [Boolean] :paginated + # @option params [Integer] :size the page size + # @option params [Integer] :page the page number + # + # @return [Hash] + # + # @example + # @client.all(size: 100, page: 0) + def all(params = {}) + get('shop/locations', params) + end + + # Retrieve details of a location + # + # @see https://developer.epages.com/beyond-docs/#show_location_details + # + # @param id [String] the location UUID + # + # @return [Hash] + # + # @example + # @client.find('869fe0f1-e5ce-491c-914e-5160a4b1cf2f') + def find(location_id) + get("shop/locations/#{location_id}") + end + + # Update a location + # + # @see https://developer.epages.com/beyond-docs/#update_location + # + # @param id [String] The language UUID + # param body [Hash] the request body + # + # @return [Hash] + # + # @example + # @client.update('869fe0f1-e5ce-491c-914e-5160a4b1cf2f', body) + def update(location_id, body) + put("shop/locations/#{location_id}", body) + end + + # Delete a location + # + # @see https://developer.epages.com/beyond-docs/#delete_location + # + # @param id [String] The language UUID + # + # @return [Hash] an empty hash + # + # @example + # @client.delete('869fe0f1-e5ce-491c-914e-5160a4b1cf2f') + def delete(location_id) + super("shop/locations/#{location_id}") + end + end + end +end diff --git a/spec/beyond_api/services/product_management/category_spec.rb b/spec/beyond_api/services/product_management/category_spec.rb index 21504d6..fae10b8 100644 --- a/spec/beyond_api/services/product_management/category_spec.rb +++ b/spec/beyond_api/services/product_management/category_spec.rb @@ -18,6 +18,11 @@ @category = client.create(build(:category_data)) end + after(:each) do + client.delete(@category[:id]) + rescue BeyondApi::Error # rubocop:disable Lint/SuppressedException + end + describe '.create' do it 'creates a new category' do expect(@category).not_to be nil @@ -51,10 +56,5 @@ expect(response).to eq({}) end end - - after(:each) do - client.delete(@category[:id]) - rescue BeyondApi::Error # rubocop:disable Lint/SuppressedException - end end end diff --git a/spec/beyond_api/services/shop/location_spec.rb b/spec/beyond_api/services/shop/location_spec.rb new file mode 100644 index 0000000..45ada88 --- /dev/null +++ b/spec/beyond_api/services/shop/location_spec.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true + +RSpec.describe BeyondApi::Shop::Location, vcr: true do + let(:client) { described_class.new(api_url: ENV.fetch('API_URL', nil), access_token: beyond_access_token) } + + describe '.all' do + it 'returns all shop locations' do + response = client.all + + expect(response).to be_present + expect(response.dig(:embedded, :locations)).to be_kind_of(Array) + expect(response[:page]).to be_kind_of(Hash) + end + end + + context 'with location' do + before(:each) do + @location = client.create(build(:location_data)) + end + + after(:each) do + client.delete(@location[:id]) + rescue BeyondApi::Error # rubocop:disable Lint/SuppressedException + end + + describe '.create' do + it 'creates a new shop location' do + expect(@location).to be_present + expect(@location[:store_code]).to eq('MLC-St-Ives') + end + end + + describe '.find' do + it 'returns a shop location' do + response = client.find(@location[:id]) + expect(response[:store_code]).to eq('MLC-St-Ives') + end + end + + describe '.update' do + it 'updates a shop location' do + updated_location_data = FactoryBot.build(:location_data, :alternative_name) + response = client.update(@location[:id], updated_location_data) + + expect(response).to be_present + expect(response[:company_name]).to eq('Updated Cornershop') + end + end + + describe '.delete' do + it 'deletes a shop location' do + response = client.delete(@location[:id]) + expect(response).to eq({}) + end + end + end +end diff --git a/spec/factories/location_data.rb b/spec/factories/location_data.rb new file mode 100644 index 0000000..8cd1d28 --- /dev/null +++ b/spec/factories/location_data.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true + +FactoryBot.define do + factory :location_data, class: Hash do + language_code { 'en' } + store_code { 'MLC-St-Ives' } + company_name { 'My little Cornershop - St.Ives' } + primary_phone { '(800) 555-0102' } + + address do + { + postal_code: '90999', + street: 'Hudson Way', + house_number: '27', + city: 'St.Ives', + country: 'GB', + dependent_locality: '', + state: 'Cornwall' + } + end + + google_status { 'ACTIVE' } + + google_primary_category do + { + category_id: 'gcid:storefood', + display_name: 'Food' + } + end + + google_additional_categories do + [ + { + display_name: 'Drinks', + category_id: 'gcid:storedrinks' + } + ] + end + + regular_hours do + { + periods: [ + { + open_day: 'MONDAY', + open_time: '08:00', + close_day: 'MONDAY', + close_time: '17:00' + }, + { + open_day: 'SATURDAY', + open_time: '10:00', + close_day: 'SATURDAY', + close_time: '16:00' + } + ] + } + end + + lat_lng do + { + latitude: 53.5847424, + longitude: 9.968901 + } + end + + trait :alternative_name do + company_name { 'Updated Cornershop' } + end + + initialize_with { attributes } + end +end diff --git a/spec/vcr_cassettes/BeyondApi_Shop_Location/_all/returns_all_shop_locations.yml b/spec/vcr_cassettes/BeyondApi_Shop_Location/_all/returns_all_shop_locations.yml new file mode 100644 index 0000000..5b6b33c --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Shop_Location/_all/returns_all_shop_locations.yml @@ -0,0 +1,136 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:18 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.211' + X-B3-Traceid: + - eefbcf59fcd29941d3044a86650abcb2 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1728571998, + "jti" : "EqWcFgvfMZ7j6HoHkvv+lsezTGI=" + } + recorded_at: Thu, 10 Oct 2024 14:53:18 GMT +- request: + method: get + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:18 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.087' + X-B3-Traceid: + - 61dc504d7a69fe05c4998f455275f405 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_embedded" : { + "locations" : [ ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/shop/locations?page=0&size=20&sort=createdAt,asc" + } + }, + "page" : { + "size" : 20, + "totalElements" : 0, + "totalPages" : 0, + "number" : 0 + } + } + recorded_at: Thu, 10 Oct 2024 14:53:18 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_create/creates_a_new_shop_location.yml b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_create/creates_a_new_shop_location.yml new file mode 100644 index 0000000..743055a --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_create/creates_a_new_shop_location.yml @@ -0,0 +1,222 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:18 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.120' + X-B3-Traceid: + - f387c0f33009487fa59ca22b547bad28 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1728571998, + "jti" : "JdpG0j3tesmecsjHCH9GnyuPPsw=" + } + recorded_at: Thu, 10 Oct 2024 14:53:18 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations + body: + encoding: UTF-8 + string: '{"languageCode":"en","storeCode":"MLC-St-Ives","companyName":"My little + Cornershop - St.Ives","primaryPhone":"(800) 555-0102","address":{"postalCode":"90999","street":"Hudson + Way","houseNumber":"27","city":"St.Ives","country":"GB","dependentLocality":"","state":"Cornwall"},"googleStatus":"ACTIVE","googlePrimaryCategory":{"categoryId":"gcid:storefood","displayName":"Food"},"googleAdditionalCategories":[{"displayName":"Drinks","categoryId":"gcid:storedrinks"}],"regularHours":{"periods":[{"openDay":"MONDAY","openTime":"08:00","closeDay":"MONDAY","closeTime":"17:00"},{"openDay":"SATURDAY","openTime":"10:00","closeDay":"SATURDAY","closeTime":"16:00"}]},"latLng":{"latitude":53.5847424,"longitude":9.968901}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 10 Oct 2024 14:53:19 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/shop/locations/b5ca0a65-b15b-44b6-93b5-99a86dfecba6 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.090' + X-B3-Traceid: + - 53e5c924c5cec8dbd06d7c8154262166 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_id" : "b5ca0a65-b15b-44b6-93b5-99a86dfecba6", + "storeCode" : "MLC-St-Ives", + "languageCode" : "en", + "address" : { + "street" : "Hudson Way", + "houseNumber" : "27", + "postalCode" : "90999", + "city" : "St.Ives", + "country" : "GB", + "dependentLocality" : "", + "state" : "Cornwall", + "displayAddressLines" : [ "27 Hudson Way", "ST.IVES", "90999", "UNITED KINGDOM" ] + }, + "companyName" : "My little Cornershop - St.Ives", + "primaryPhone" : "(800) 555-0102", + "googleStatus" : "ACTIVE", + "googlePrimaryCategory" : { + "displayName" : "Food", + "categoryId" : "gcid:storefood" + }, + "googleAdditionalCategories" : [ { + "displayName" : "Drinks", + "categoryId" : "gcid:storedrinks" + } ], + "latLng" : { + "latitude" : 53.5847424, + "longitude" : 9.968901 + }, + "regularHours" : { + "periods" : [ { + "openDay" : "MONDAY", + "openTime" : "08:00", + "closeDay" : "MONDAY", + "closeTime" : "17:00" + }, { + "openDay" : "SATURDAY", + "openTime" : "10:00", + "closeDay" : "SATURDAY", + "closeTime" : "16:00" + } ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/shop/locations/b5ca0a65-b15b-44b6-93b5-99a86dfecba6" + } + } + } + recorded_at: Thu, 10 Oct 2024 14:53:19 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations/b5ca0a65-b15b-44b6-93b5-99a86dfecba6 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 10 Oct 2024 14:53:19 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.056' + X-B3-Traceid: + - 0beabd9e843630d6e38e45f61804baa0 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 10 Oct 2024 14:53:19 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_delete/deletes_a_shop_location.yml b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_delete/deletes_a_shop_location.yml new file mode 100644 index 0000000..308ea95 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_delete/deletes_a_shop_location.yml @@ -0,0 +1,274 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:21 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.131' + X-B3-Traceid: + - 9a937df50e5c4e91a56a9b278161012c + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1728572001, + "jti" : "d+nVa4xkMmsYZygYWfY4v+y2dJI=" + } + recorded_at: Thu, 10 Oct 2024 14:53:21 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations + body: + encoding: UTF-8 + string: '{"languageCode":"en","storeCode":"MLC-St-Ives","companyName":"My little + Cornershop - St.Ives","primaryPhone":"(800) 555-0102","address":{"postalCode":"90999","street":"Hudson + Way","houseNumber":"27","city":"St.Ives","country":"GB","dependentLocality":"","state":"Cornwall"},"googleStatus":"ACTIVE","googlePrimaryCategory":{"categoryId":"gcid:storefood","displayName":"Food"},"googleAdditionalCategories":[{"displayName":"Drinks","categoryId":"gcid:storedrinks"}],"regularHours":{"periods":[{"openDay":"MONDAY","openTime":"08:00","closeDay":"MONDAY","closeTime":"17:00"},{"openDay":"SATURDAY","openTime":"10:00","closeDay":"SATURDAY","closeTime":"16:00"}]},"latLng":{"latitude":53.5847424,"longitude":9.968901}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 10 Oct 2024 14:53:21 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/shop/locations/20840fc4-aa39-4571-bd62-13d15f01f249 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.054' + X-B3-Traceid: + - 02f94379b9a014ac81fefac8c25c82a9 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_id" : "20840fc4-aa39-4571-bd62-13d15f01f249", + "storeCode" : "MLC-St-Ives", + "languageCode" : "en", + "address" : { + "street" : "Hudson Way", + "houseNumber" : "27", + "postalCode" : "90999", + "city" : "St.Ives", + "country" : "GB", + "dependentLocality" : "", + "state" : "Cornwall", + "displayAddressLines" : [ "27 Hudson Way", "ST.IVES", "90999", "UNITED KINGDOM" ] + }, + "companyName" : "My little Cornershop - St.Ives", + "primaryPhone" : "(800) 555-0102", + "googleStatus" : "ACTIVE", + "googlePrimaryCategory" : { + "displayName" : "Food", + "categoryId" : "gcid:storefood" + }, + "googleAdditionalCategories" : [ { + "displayName" : "Drinks", + "categoryId" : "gcid:storedrinks" + } ], + "latLng" : { + "latitude" : 53.5847424, + "longitude" : 9.968901 + }, + "regularHours" : { + "periods" : [ { + "openDay" : "MONDAY", + "openTime" : "08:00", + "closeDay" : "MONDAY", + "closeTime" : "17:00" + }, { + "openDay" : "SATURDAY", + "openTime" : "10:00", + "closeDay" : "SATURDAY", + "closeTime" : "16:00" + } ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/shop/locations/20840fc4-aa39-4571-bd62-13d15f01f249" + } + } + } + recorded_at: Thu, 10 Oct 2024 14:53:21 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations/20840fc4-aa39-4571-bd62-13d15f01f249 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 10 Oct 2024 14:53:21 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.052' + X-B3-Traceid: + - f2af1fec575148c96fae7d920f8b5749 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 10 Oct 2024 14:53:21 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations/20840fc4-aa39-4571-bd62-13d15f01f249 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 404 + message: Not Found + headers: + Date: + - Thu, 10 Oct 2024 14:53:21 GMT + Content-Length: + - '0' + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.015' + X-B3-Traceid: + - f496317e9c7d50d5f7aef92a7fc71001 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 10 Oct 2024 14:53:21 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_find/returns_a_shop_location.yml b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_find/returns_a_shop_location.yml new file mode 100644 index 0000000..72f0d03 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_find/returns_a_shop_location.yml @@ -0,0 +1,324 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:19 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.099' + X-B3-Traceid: + - 78645c4ac81e4ed07b2665a50f8f0dae + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1728571999, + "jti" : "2zmmYhwZMMJH2I/DndPH0A8sYKk=" + } + recorded_at: Thu, 10 Oct 2024 14:53:19 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations + body: + encoding: UTF-8 + string: '{"languageCode":"en","storeCode":"MLC-St-Ives","companyName":"My little + Cornershop - St.Ives","primaryPhone":"(800) 555-0102","address":{"postalCode":"90999","street":"Hudson + Way","houseNumber":"27","city":"St.Ives","country":"GB","dependentLocality":"","state":"Cornwall"},"googleStatus":"ACTIVE","googlePrimaryCategory":{"categoryId":"gcid:storefood","displayName":"Food"},"googleAdditionalCategories":[{"displayName":"Drinks","categoryId":"gcid:storedrinks"}],"regularHours":{"periods":[{"openDay":"MONDAY","openTime":"08:00","closeDay":"MONDAY","closeTime":"17:00"},{"openDay":"SATURDAY","openTime":"10:00","closeDay":"SATURDAY","closeTime":"16:00"}]},"latLng":{"latitude":53.5847424,"longitude":9.968901}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 10 Oct 2024 14:53:19 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/shop/locations/952797f5-b36d-4808-9c38-b4fd4e498190 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.045' + X-B3-Traceid: + - 88177eb05756b661bdb2f1cd99562961 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_id" : "952797f5-b36d-4808-9c38-b4fd4e498190", + "storeCode" : "MLC-St-Ives", + "languageCode" : "en", + "address" : { + "street" : "Hudson Way", + "houseNumber" : "27", + "postalCode" : "90999", + "city" : "St.Ives", + "country" : "GB", + "dependentLocality" : "", + "state" : "Cornwall", + "displayAddressLines" : [ "27 Hudson Way", "ST.IVES", "90999", "UNITED KINGDOM" ] + }, + "companyName" : "My little Cornershop - St.Ives", + "primaryPhone" : "(800) 555-0102", + "googleStatus" : "ACTIVE", + "googlePrimaryCategory" : { + "displayName" : "Food", + "categoryId" : "gcid:storefood" + }, + "googleAdditionalCategories" : [ { + "displayName" : "Drinks", + "categoryId" : "gcid:storedrinks" + } ], + "latLng" : { + "latitude" : 53.5847424, + "longitude" : 9.968901 + }, + "regularHours" : { + "periods" : [ { + "openDay" : "MONDAY", + "openTime" : "08:00", + "closeDay" : "MONDAY", + "closeTime" : "17:00" + }, { + "openDay" : "SATURDAY", + "openTime" : "10:00", + "closeDay" : "SATURDAY", + "closeTime" : "16:00" + } ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/shop/locations/952797f5-b36d-4808-9c38-b4fd4e498190" + } + } + } + recorded_at: Thu, 10 Oct 2024 14:53:19 GMT +- request: + method: get + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations/952797f5-b36d-4808-9c38-b4fd4e498190 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:20 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.049' + X-B3-Traceid: + - 1ad2d92a822cd8684ea86b3f0191bf85 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_id" : "952797f5-b36d-4808-9c38-b4fd4e498190", + "storeCode" : "MLC-St-Ives", + "languageCode" : "en", + "address" : { + "street" : "Hudson Way", + "houseNumber" : "27", + "postalCode" : "90999", + "city" : "St.Ives", + "country" : "GB", + "dependentLocality" : "", + "state" : "Cornwall", + "displayAddressLines" : [ "27 Hudson Way", "ST.IVES", "90999", "UNITED KINGDOM" ] + }, + "companyName" : "My little Cornershop - St.Ives", + "primaryPhone" : "(800) 555-0102", + "googleStatus" : "ACTIVE", + "googlePrimaryCategory" : { + "displayName" : "Food", + "categoryId" : "gcid:storefood" + }, + "googleAdditionalCategories" : [ { + "displayName" : "Drinks", + "categoryId" : "gcid:storedrinks" + } ], + "latLng" : { + "latitude" : 53.5847424, + "longitude" : 9.968901 + }, + "regularHours" : { + "periods" : [ { + "openDay" : "MONDAY", + "openTime" : "08:00", + "closeDay" : "MONDAY", + "closeTime" : "17:00" + }, { + "openDay" : "SATURDAY", + "openTime" : "10:00", + "closeDay" : "SATURDAY", + "closeTime" : "16:00" + } ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/shop/locations/952797f5-b36d-4808-9c38-b4fd4e498190" + } + } + } + recorded_at: Thu, 10 Oct 2024 14:53:19 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations/952797f5-b36d-4808-9c38-b4fd4e498190 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 10 Oct 2024 14:53:20 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.049' + X-B3-Traceid: + - 24c9814ac54e1f6927b5099cc07dee6b + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 10 Oct 2024 14:53:20 GMT +recorded_with: VCR 6.2.0 diff --git a/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_update/updates_a_shop_location.yml b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_update/updates_a_shop_location.yml new file mode 100644 index 0000000..4cbcc68 --- /dev/null +++ b/spec/vcr_cassettes/BeyondApi_Shop_Location/with_location/_update/updates_a_shop_location.yml @@ -0,0 +1,326 @@ +--- +http_interactions: +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/oauth/token?grant_type=client_credentials + body: + encoding: UTF-8 + string: "{}" + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Basic + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:20 GMT + Content-Type: + - application/json;charset=utf-8 + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Cache-Control: + - no-store + Pragma: + - no-cache + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Strict-Transport-Security: + - max-age=31536000 ; includeSubDomains + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.104' + X-B3-Traceid: + - 1d26a32ed743bc965773c38dc508604e + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "access_token" : "", + "token_type" : "bearer", + "expires_in" : 3599, + "scope" : "orde:r prat:dcur pypr:cur prod:urdc lcnt:u pymt:ur loca:urcd sctg:m shat:cdru rfpr:ur prad:rcd shpz:dcur shad:u ordr:cur shop:u shim:cd cust:urcd clpr:cr legl:ur prda:ru rtpr:rc oset:ur shpr:rcu cset:ru ordp:r catg:cdur nltg:m", + "tenantId" : 8542, + "iat" : 1728572000, + "jti" : "fV/S1GqKoBkytwszksGTzzh/qFI=" + } + recorded_at: Thu, 10 Oct 2024 14:53:20 GMT +- request: + method: post + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations + body: + encoding: UTF-8 + string: '{"languageCode":"en","storeCode":"MLC-St-Ives","companyName":"My little + Cornershop - St.Ives","primaryPhone":"(800) 555-0102","address":{"postalCode":"90999","street":"Hudson + Way","houseNumber":"27","city":"St.Ives","country":"GB","dependentLocality":"","state":"Cornwall"},"googleStatus":"ACTIVE","googlePrimaryCategory":{"categoryId":"gcid:storefood","displayName":"Food"},"googleAdditionalCategories":[{"displayName":"Drinks","categoryId":"gcid:storedrinks"}],"regularHours":{"periods":[{"openDay":"MONDAY","openTime":"08:00","closeDay":"MONDAY","closeTime":"17:00"},{"openDay":"SATURDAY","openTime":"10:00","closeDay":"SATURDAY","closeTime":"16:00"}]},"latLng":{"latitude":53.5847424,"longitude":9.968901}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 201 + message: Created + headers: + Date: + - Thu, 10 Oct 2024 14:53:20 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + Location: + - https://team42-beyond-api.beyondshop.cloud/api/shop/locations/ca139c15-93d7-4abb-b315-c624e7f77ea8 + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.085' + X-B3-Traceid: + - 884d6a5019102a351e66e0a04a8f76f8 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_id" : "ca139c15-93d7-4abb-b315-c624e7f77ea8", + "storeCode" : "MLC-St-Ives", + "languageCode" : "en", + "address" : { + "street" : "Hudson Way", + "houseNumber" : "27", + "postalCode" : "90999", + "city" : "St.Ives", + "country" : "GB", + "dependentLocality" : "", + "state" : "Cornwall", + "displayAddressLines" : [ "27 Hudson Way", "ST.IVES", "90999", "UNITED KINGDOM" ] + }, + "companyName" : "My little Cornershop - St.Ives", + "primaryPhone" : "(800) 555-0102", + "googleStatus" : "ACTIVE", + "googlePrimaryCategory" : { + "displayName" : "Food", + "categoryId" : "gcid:storefood" + }, + "googleAdditionalCategories" : [ { + "displayName" : "Drinks", + "categoryId" : "gcid:storedrinks" + } ], + "latLng" : { + "latitude" : 53.5847424, + "longitude" : 9.968901 + }, + "regularHours" : { + "periods" : [ { + "openDay" : "MONDAY", + "openTime" : "08:00", + "closeDay" : "MONDAY", + "closeTime" : "17:00" + }, { + "openDay" : "SATURDAY", + "openTime" : "10:00", + "closeDay" : "SATURDAY", + "closeTime" : "16:00" + } ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/shop/locations/ca139c15-93d7-4abb-b315-c624e7f77ea8" + } + } + } + recorded_at: Thu, 10 Oct 2024 14:53:20 GMT +- request: + method: put + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations/ca139c15-93d7-4abb-b315-c624e7f77ea8 + body: + encoding: UTF-8 + string: '{"languageCode":"en","storeCode":"MLC-St-Ives","companyName":"Updated + Cornershop","primaryPhone":"(800) 555-0102","address":{"postalCode":"90999","street":"Hudson + Way","houseNumber":"27","city":"St.Ives","country":"GB","dependentLocality":"","state":"Cornwall"},"googleStatus":"ACTIVE","googlePrimaryCategory":{"categoryId":"gcid:storefood","displayName":"Food"},"googleAdditionalCategories":[{"displayName":"Drinks","categoryId":"gcid:storedrinks"}],"regularHours":{"periods":[{"openDay":"MONDAY","openTime":"08:00","closeDay":"MONDAY","closeTime":"17:00"},{"openDay":"SATURDAY","openTime":"10:00","closeDay":"SATURDAY","closeTime":"16:00"}]},"latLng":{"latitude":53.5847424,"longitude":9.968901}}' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 200 + message: OK + headers: + Date: + - Thu, 10 Oct 2024 14:53:20 GMT + Content-Type: + - application/json + Transfer-Encoding: + - chunked + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.054' + X-B3-Traceid: + - b6769cba57e4732b78c2c5407b184c4a + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: |- + { + "_id" : "ca139c15-93d7-4abb-b315-c624e7f77ea8", + "storeCode" : "MLC-St-Ives", + "languageCode" : "en", + "address" : { + "street" : "Hudson Way", + "houseNumber" : "27", + "postalCode" : "90999", + "city" : "St.Ives", + "country" : "GB", + "dependentLocality" : "", + "state" : "Cornwall", + "displayAddressLines" : [ "27 Hudson Way", "ST.IVES", "90999", "UNITED KINGDOM" ] + }, + "companyName" : "Updated Cornershop", + "primaryPhone" : "(800) 555-0102", + "googleStatus" : "ACTIVE", + "googlePrimaryCategory" : { + "displayName" : "Food", + "categoryId" : "gcid:storefood" + }, + "googleAdditionalCategories" : [ { + "displayName" : "Drinks", + "categoryId" : "gcid:storedrinks" + } ], + "latLng" : { + "latitude" : 53.5847424, + "longitude" : 9.968901 + }, + "regularHours" : { + "periods" : [ { + "openDay" : "MONDAY", + "openTime" : "08:00", + "closeDay" : "MONDAY", + "closeTime" : "17:00" + }, { + "openDay" : "SATURDAY", + "openTime" : "10:00", + "closeDay" : "SATURDAY", + "closeTime" : "16:00" + } ] + }, + "_links" : { + "self" : { + "href" : "https://team42-beyond-api.beyondshop.cloud/api/shop/locations/ca139c15-93d7-4abb-b315-c624e7f77ea8" + } + } + } + recorded_at: Thu, 10 Oct 2024 14:53:20 GMT +- request: + method: delete + uri: https://team42-beyond-api.beyondshop.cloud/api/shop/locations/ca139c15-93d7-4abb-b315-c624e7f77ea8 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - application/json + Content-Type: + - application/json + User-Agent: + - Faraday v2.10.1 + Authorization: + - Bearer + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + response: + status: + code: 204 + message: No Content + headers: + Date: + - Thu, 10 Oct 2024 14:53:21 GMT + Connection: + - keep-alive + X-Content-Type-Options: + - nosniff + X-Xss-Protection: + - 1; mode=block + Cache-Control: + - no-cache, no-store, max-age=0, must-revalidate + Pragma: + - no-cache + Expires: + - '0' + X-Frame-Options: + - DENY + Server: + - epages-beyond + X-Request-Time: + - '0.047' + X-B3-Traceid: + - 6b389ffff2b29cc702455515224f9c90 + X-Hello-Human: + - Come work with us! https://developer.epages.com/devjobs/ + body: + encoding: UTF-8 + string: '' + recorded_at: Thu, 10 Oct 2024 14:53:21 GMT +recorded_with: VCR 6.2.0