Skip to content

Commit 9e9a8dd

Browse files
author
Unai Abrisketa
committed
Fix rubocop
1 parent ca94d82 commit 9e9a8dd

File tree

15 files changed

+60
-41
lines changed

15 files changed

+60
-41
lines changed

Rakefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
# frozen_string_literal: true
2+
13
require "bundler/gem_tasks"
24
require "rspec/core/rake_task"
35
require "yard"
46

57
RSpec::Core::RakeTask.new(:spec)
68

7-
task :default => :spec
9+
task default: :spec
810

911
YARD::Rake::YardocTask.new do |t|
10-
t.files = ['lib/**/*.rb']
12+
t.files = ["lib/**/*.rb"]
1113
end

bin/console

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
# frozen_string_literal: true
12
#!/usr/bin/env ruby
23

34
require "bundler/setup"
45
require "dotenv/load"
56
require "beyond_api"
67

7-
unless ENV["CLIENT_ID"].nil? and ENV["CLIENT_SECRET"].nil?
8+
unless ENV["CLIENT_ID"].nil? && ENV["CLIENT_SECRET"].nil?
89
BeyondApi.setup do |config|
910
config.client_id = ENV["CLIENT_ID"]
1011
config.client_secret = ENV["CLIENT_SECRET"]

lib/beyond_api.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require "beyond_api/version"
24

35
require "logger"

lib/beyond_api/resources/carts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def replace_line_item(cart_id, line_item_id, body)
315315
# body = [ {
316316
# "_type" => "PRODUCT",
317317
# "_ref" => "0612362d-9856-4b40-94c6-a36abec0cf8c",
318-
# "quantity" => 1
318+
# "quantity" => 1
319319
# } ]
320320
#
321321
# @cart = session.carts.replace_line_items("c1436110-e283-49b3-a748-0321efec6d35", body)

lib/beyond_api/resources/products.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ def assign_variation_attribute_as_differentiator(product_id, variation_attribute
276276
handle_response(response, status, respond_with_true: true)
277277
end
278278

279-
alias_method :create_variation, :create
280-
alias_method :find_variation, :find
281-
alias_method :update_variation, :update
279+
alias create_variation create
280+
alias find_variation find
281+
alias update_variation update
282282
end
283283
end

lib/beyond_api/resources/products/images.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -187,13 +187,13 @@ def sort_images(product_id, image_ids)
187187
#
188188
def upload_image(product_id, image_path, image_name)
189189
content_type = case File.extname(image_path)
190-
when ".png"
191-
"image/png"
192-
when ".jpg", ".jpeg"
193-
"image/jpeg"
194-
when ".gif"
195-
"image/gif"
196-
end
190+
when ".png"
191+
"image/png"
192+
when ".jpg", ".jpeg"
193+
"image/jpeg"
194+
when ".gif"
195+
"image/gif"
196+
end
197197
image_binary = File.binread(image_path)
198198

199199
response, status = BeyondApi::Request.upload(@session, "/products/#{product_id}/images", image_binary, content_type, { file_name: image_name })

lib/beyond_api/resources/shops/images.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,13 @@ def search_images_by_label(label)
138138
#
139139
def upload_image(image_path, image_name, label)
140140
content_type = case File.extname(image_path)
141-
when ".png"
142-
"image/png"
143-
when ".jpg", ".jpeg"
144-
"image/jpeg"
145-
when ".gif"
146-
"image/gif"
147-
end
141+
when ".png"
142+
"image/png"
143+
when ".jpg", ".jpeg"
144+
"image/jpeg"
145+
when ".gif"
146+
"image/gif"
147+
end
148148
image_binary = File.binread(image_path)
149149

150150
response, status = BeyondApi::Request.upload(@session, "/shop/images", image_binary, content_type, { file_name: image_name, label: label })

lib/beyond_api/resources/shops/legals.rb

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ module ShopLegals
2020
# @legal_content = session.shop.legal_content("right-of-withdrawal")
2121
#
2222
def legal_content(legal_content_type)
23-
response, status = BeyondApi::Request.get(@session, "/legal-content/#{legal_content_type}")
23+
response, status = BeyondApi::Request.get(@session,
24+
"/legal-content/#{legal_content_type}")
2425

2526
handle_response(response, status)
2627
end
@@ -41,7 +42,9 @@ def legal_content(legal_content_type)
4142
# @legal_content = session.shop.legal_contents(size: 5, page: 1)
4243
#
4344
def legal_contents(params = {})
44-
response, status = BeyondApi::Request.get(@session, "/legal-content", params)
45+
response, status = BeyondApi::Request.get(@session,
46+
"/legal-content",
47+
params)
4548

4649
handle_response(response, status)
4750
end
@@ -60,12 +63,13 @@ def legal_contents(params = {})
6063
# @legal_details = session.shop.legal_details
6164
#
6265
def legal_details
63-
response, status = BeyondApi::Request.get(@session, "/shop/legal")
66+
response, status = BeyondApi::Request.get(@session,
67+
"/shop/legal")
6468

6569
handle_response(response, status)
6670
end
6771

68-
#
72+
#
6973
# A +PUT+ request is used to update the content of a specific part of the legal content information. Changes on the properties type and mandatory will be ignored.
7074
#
7175
# $ curl 'https://api-shop.beyondshop.cloud/api/legal-content/legal-notice' -i -X PUT \
@@ -86,7 +90,9 @@ def legal_details
8690
# session.shop.update_legal_content(body)
8791
#
8892
def update_legal_content(body)
89-
response, status = BeyondApi::Request.put(@session, "/legal-content/legal-notice")
93+
response, status = BeyondApi::Request.put(@session,
94+
"/legal-content/legal-notice",
95+
body)
9096

9197
handle_response(response, status)
9298
end
@@ -116,7 +122,9 @@ def update_legal_content(body)
116122
# session.shop.update_legal_details(body)
117123
#
118124
def update_legal_details(body)
119-
response, status = BeyondApi::Request.patch(@session, "/shop/legal")
125+
response, status = BeyondApi::Request.patch(@session,
126+
"/shop/legal",
127+
body)
120128

121129
handle_response(response, status)
122130
end

lib/beyond_api/resources/token.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ def client_credentials
2929
handle_token_call("client_credentials")
3030
end
3131

32-
alias_method :refresh, :refresh_token
33-
alias_method :create, :authorization_code
32+
alias refresh refresh_token
33+
alias create authorization_code
3434

3535
private
3636

lib/beyond_api/resources/variations/images.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ module VariationImages
3636
#
3737
def add_image(product_id, variation_id, body)
3838
response, status = BeyondApi::Request.post(@session, "/products/#{product_id}/variations/#{variation_id}/images", body)
39-
39+
4040
handle_response(response, status)
4141
end
4242

@@ -143,13 +143,13 @@ def images(product_id, variation_id, params = {})
143143
#
144144
def upload_image(product_id, variation_id, image_path, image_name)
145145
content_type = case File.extname(image_path)
146-
when ".png"
147-
"image/png"
148-
when ".jpg", ".jpeg"
149-
"image/jpeg"
150-
when ".gif"
151-
"image/gif"
152-
end
146+
when ".png"
147+
"image/png"
148+
when ".jpg", ".jpeg"
149+
"image/jpeg"
150+
when ".gif"
151+
"image/gif"
152+
end
153153
image_binary = File.binread(image_path)
154154

155155
response, status = BeyondApi::Request.upload(@session, "/products/#{product_id}/variations/#{variation_id}/images", image_binary, content_type, { file_name: image_name })

0 commit comments

Comments
 (0)