Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
Merge pull request #49 from panxl6/master
Browse files Browse the repository at this point in the history
fix checks for required values when nil is passed
  • Loading branch information
Bossa573 authored Jan 2, 2024
2 parents bb5d7a9 + 0f3df60 commit 2227b37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/aftership/v4/last_checkpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module AfterShip
module V4
class LastCheckpoint < AfterShip::V4::Base
def self.get(slug = '', tracking_number = '')
if slug.empty? || tracking_number.empty?
if slug.nil? || slug.empty? || tracking_number.nil? || tracking_number.empty?
raise ArgumentError, 'slug and tracking_number are required.'
else
new(:get, "last_checkpoint/#{slug}/#{tracking_number}").call
Expand Down
12 changes: 6 additions & 6 deletions lib/aftership/v4/tracking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module V4
class Tracking < AfterShip::V4::Base
# POST /trackings
def self.create(tracking_number, params = {})
if tracking_number.empty? || tracking_number.nil?
if tracking_number.nil? || tracking_number.empty?
raise ArgumentError, 'tracking_number is required.'
else
query_hash = { tracking_number: tracking_number }
Expand All @@ -17,7 +17,7 @@ def self.create(tracking_number, params = {})

# POST /trackings/:slug/:tracking_number/retrack
def self.retrack(slug, tracking_number, params = {})
if slug.empty? || slug.nil? || tracking_number.empty? || tracking_number.nil?
if slug.nil? || slug.empty? || tracking_number.nil? || tracking_number.empty?
raise ArgumentError, 'slug and tracking_number are required.'
end

Expand All @@ -26,7 +26,7 @@ def self.retrack(slug, tracking_number, params = {})

# DELETE /trackings/:slug/:tracking_number
def self.delete(slug, tracking_number, params = {})
if slug.empty? || slug.nil? || tracking_number.empty? || tracking_number.nil?
if slug.nil? || slug.empty? || tracking_number.nil? || tracking_number.empty?
raise ArgumentError, 'slug and tracking_number are required.'
end

Expand All @@ -42,7 +42,7 @@ def self.delete_by_id(id)

# GET /trackings/:slug/:tracking_number
def self.get(slug, tracking_number, params = {})
if slug.empty? || slug.nil? || tracking_number.empty? || tracking_number.nil?
if slug.nil? || slug.empty? || tracking_number.nil? || tracking_number.empty?
raise ArgumentError, 'slug and tracking_number are required.'
end

Expand All @@ -51,7 +51,7 @@ def self.get(slug, tracking_number, params = {})

# GET /trackings/:id
def self.get_by_id(id, params = {})
raise ArgumentError, 'id is required.' if id.empty? || id.nil?
raise ArgumentError, 'id is required.' if id.nil? || id.empty?

new(:get, "trackings/#{id}", params).call
end
Expand All @@ -68,7 +68,7 @@ def self.export(params = {})

# PUT /trackings/:slug/:tracking_number
def self.update(slug, tracking_number, params = {})
if slug.empty? || slug.nil? || tracking_number.empty? || tracking_number.nil?
if slug.nil? || slug.empty? || tracking_number.nil? || tracking_number.empty?
raise ArgumentError, 'slug and tracking_number are required.'
end

Expand Down

0 comments on commit 2227b37

Please sign in to comment.