Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,7 @@ end

group :test do
gem "factory_bot"
gem "jwt"
gem "vcr"
gem "webmock"
end
24 changes: 15 additions & 9 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.1.3.4)
activesupport (7.2.0)
base64
bigdecimal
concurrent-ruby (~> 1.0, >= 1.0.2)
concurrent-ruby (~> 1.0, >= 1.3.1)
connection_pool (>= 2.2.5)
drb
i18n (>= 1.6, < 2)
logger (>= 1.4.2)
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
ast (2.4.2)
base64 (0.2.0)
bigdecimal (3.1.8)
coderay (1.1.3)
concurrent-ruby (1.3.3)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crack (1.0.0)
bigdecimal
Expand All @@ -49,15 +50,16 @@ GEM
i18n (1.14.5)
concurrent-ruby (~> 1.0)
json (2.7.2)
jwt (2.8.2)
base64
language_server-protocol (3.17.0.3)
logger (1.6.0)
method_source (1.1.0)
minitest (5.24.1)
mutex_m (0.2.0)
net-http (0.4.1)
uri
parallel (1.25.1)
parser (3.3.4.0)
parallel (1.26.2)
parser (3.3.4.2)
ast (~> 2.4.1)
racc
pry (0.14.2)
Expand All @@ -68,7 +70,7 @@ GEM
rainbow (3.1.1)
rake (10.5.0)
regexp_parser (2.9.2)
rexml (3.3.4)
rexml (3.3.5)
strscan
rspec (3.13.0)
rspec-core (~> 3.13.0)
Expand Down Expand Up @@ -108,11 +110,13 @@ GEM
rubocop-rspec_rails (2.29.1)
rubocop (~> 1.61)
ruby-progressbar (1.13.0)
securerandom (0.3.1)
strscan (3.1.0)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.5.0)
uri (0.13.0)
vcr (6.2.0)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
Expand All @@ -130,11 +134,13 @@ DEPENDENCIES
dotenv (~> 2.7)
factory_bot
faker (~> 2.2)
jwt
pry
rake (~> 10.0)
rspec (~> 3.0)
rubocop
rubocop-rspec (~> 2.4)
vcr
webmock
yard (~> 0.9)

Expand Down
3 changes: 0 additions & 3 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ unless ENV["CLIENT_ID"].nil? && ENV["CLIENT_SECRET"].nil?
BeyondApi.setup do |config|
config.client_id = ENV["CLIENT_ID"]
config.client_secret = ENV["CLIENT_SECRET"]
config.remove_response_links = true
config.remove_response_key_underscores = true
config.object_struct_responses = false
end
end

Expand Down
9 changes: 9 additions & 0 deletions lib/beyond_api/concerns/connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ def get(path, params = {})
handle_request { agent.get(path, parse_request(params)) }
end

def put(path, body = {}, params = {})
handle_request do
agent.put(path, body) do |request|
request.params = parse_request(params)
request.body = parse_request(body)
end
end
end

def post(path, body = {}, params = {})
handle_request do
agent.post(path, body) do |request|
Expand Down
4 changes: 2 additions & 2 deletions lib/beyond_api/services/authentication/signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ def create
post("signers")
end

def destroy(id)
delete("signers/#{id}")
def delete(id)
super("signers/#{id}") # Concerns::Connection delete method
end
end
end
Expand Down
16 changes: 16 additions & 0 deletions lib/beyond_api/services/product_management/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@ class Category < BaseService
def find(id)
get("categories/#{id}")
end

def all(params = {})
fetch_all_pages("categories", params)
end

def create(body)
post("categories", body)
end

def update(id, body)
put("categories/#{id}", body)
end

def delete(id)
super("categories/#{id}") # Concerns::Connection delete method
end
end
end
end
2 changes: 1 addition & 1 deletion lib/beyond_api/services/product_management/image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module BeyondApi
module ProductManagement
class Image < BaseService
def all(id, params = {})
get("products/#{id}/images")
get("products/#{id}/images", params)
end
end
end
Expand Down
6 changes: 5 additions & 1 deletion lib/beyond_api/services/product_management/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module BeyondApi
module ProductManagement
class Product < BaseService
def all(params = {})
fetch_all_pages("/products", params)
fetch_all_pages("products", params)
end

def create(body)
post("products", body)
end

def find(id)
Expand Down
2 changes: 1 addition & 1 deletion lib/beyond_api/services/product_management/variation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module BeyondApi
module ProductManagement
class Variation < BaseService
def all(id, params = {})
get("products/#{id}/variations")
get("products/#{id}/variations", params)
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/beyond_api/services/storefront/script_tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ def create(script_url)
post("script-tags", script_url:)
end

def destroy(id)
delete("script-tags/#{id}")
def delete(id)
super("script-tags/#{id}") # Concerns::Connection delete method
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/beyond_api/services/webhook/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ def create(body)

def delete_all
all.dig(:embedded, :subscriptions).each do |subscription|
destroy(subscription[:id])
delete(subscription[:id])
end
end

def destroy(id)
delete("webhook-subscriptions/#{id}")
def delete(id)
super("webhook-subscriptions/#{id}") # Concerns::Connection delete method
end

def find(id)
Expand Down
78 changes: 0 additions & 78 deletions spec/beyond_api/resources/products_spec.rb

This file was deleted.

15 changes: 0 additions & 15 deletions spec/beyond_api/resources/products_view_spec.rb

This file was deleted.

Loading