sendle_api 0.1.0 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 386a566c5290868a2c87a9fa784d326a4414ff460e94cb72df849a90f2b797a3
4
- data.tar.gz: add9b3a6795ba309494b21d0a634870d49a5d9107854b3eacc31b5ed332cef15
3
+ metadata.gz: 7e44918e10ca83b0d05d242cbf0311c79e84b8e80a0618be6e099d300da2f4ac
4
+ data.tar.gz: 4aa87b10d953856785402638e155202405b98d8d61757ed7144b415db3cfe80b
5
5
  SHA512:
6
- metadata.gz: 5dbb20a21b4a87bf642f70d930967a5e7bd8d1194921519b8dc8682659506ab300a54d5cb36dbec02cc35b188c580282c3fe796c0d9b76462712c799b0a32a9c
7
- data.tar.gz: 1af00478d6980c7ba3d06f24d53b9fc50ab274e6658daf2a5ccd350cc81e106a074f0133fb3e20bdaee681edd7cc7b3d02ac989ff083fb4f2dd3104595dc6b4b
6
+ metadata.gz: 7baa761f0218c16a39e60eb7ddfc51db5e389cdfa38d91a9532d318ddbb79c8318f1ae0d037a2d8ef81a23b6295ac85f203973678d7861af10fa51b2f78c0746
7
+ data.tar.gz: 8562dd99a2dedaa8249b25a8c02cdd105e20c632bb1800357a26243fd4fb0253a4ab981b3265e9cee333f10c73b862be33f0ef4b9171120174eb02caf91da343
data/.rubocop.yml ADDED
@@ -0,0 +1,43 @@
1
+ inherit_gem:
2
+ rubocop-shopify: rubocop.yml
3
+
4
+ AllCops:
5
+ NewCops: enable
6
+
7
+ Layout/FirstArrayElementLineBreak:
8
+ Enabled: true
9
+
10
+ Layout/FirstMethodArgumentLineBreak:
11
+ Enabled: true
12
+
13
+ Layout/FirstArgumentIndentation:
14
+ Enabled: true
15
+ EnforcedStyle: consistent
16
+
17
+ Layout/FirstParameterIndentation:
18
+ Enabled: true
19
+ EnforcedStyle: consistent
20
+
21
+ Layout/MultilineMethodArgumentLineBreaks:
22
+ Enabled: true
23
+
24
+ Layout/MultilineOperationIndentation:
25
+ Enabled: true
26
+
27
+ Style/MethodCallWithArgsParentheses:
28
+ Enabled: true
29
+ IgnoreMacros: true
30
+ IgnoredMethods:
31
+ - require
32
+ - require_relative
33
+ - require_dependency
34
+ - yield
35
+ - raise
36
+ - puts
37
+ - to
38
+ - not_to
39
+ - to_not
40
+ - describe
41
+ Exclude:
42
+ - "**/Gemfile"
43
+ - "db/**/*"
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  source "https://rubygems.org"
2
3
 
3
4
  # Specify your gem's dependencies in sendle_api.gemspec
data/lib/dev/config.rb CHANGED
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "dotenv/load"
2
4
 
3
5
  def set_config
4
6
  SendleAPI.configure do |config|
5
- config.sendle_id = ENV["SENDLE_ID"]
7
+ config.sendle_id = ENV["SENDLE_ID"]
6
8
  config.api_key = ENV["SENDLE_API_KEY"]
7
9
  config.testing = true
8
10
  end
9
- end
11
+ end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "zeitwerk"
2
4
  require_relative "config"
3
5
 
4
6
  loader = Zeitwerk::Loader.for_gem
5
7
  loader.inflector.inflect(
6
- "sendle_api" => "SendleAPI"
8
+ "sendle_api" => "SendleAPI",
7
9
  )
8
10
  loader.push_dir("./lib")
9
11
  loader.collapse("./lib/sendle_api/resources")
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Configuration
3
5
  attr_accessor :sendle_id, :api_key, :testing
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Address < Base
3
5
  include NotSaveable
@@ -7,9 +9,9 @@ module SendleAPI
7
9
  suburb: nil,
8
10
  state_name: nil,
9
11
  postcode: nil,
10
- country: nil
12
+ country: nil,
11
13
  }
12
14
 
13
15
  validates :address_line1, :suburb, :state_name, :postcode, :country, presence: true
14
16
  end
15
- end
17
+ end
@@ -1,12 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Base < ::ActiveResource::Base
3
-
4
5
  validate :child_object_validations
5
6
 
6
7
  self.include_root_in_json = false
7
8
  self.include_format_in_path = false
8
9
  self.connection_class = Connection
9
- self.prefix = '/api/'
10
+ self.prefix = "/api/"
10
11
 
11
12
  def initialize(attributes = {}, persisted = false)
12
13
  if defined?(self.class::DEFAULT_ATTRS)
@@ -19,7 +20,7 @@ module SendleAPI
19
20
  self.class.validate_configs
20
21
  super
21
22
  end
22
-
23
+
23
24
  def errors
24
25
  @errors ||= Errors.new(self)
25
26
  end
@@ -29,11 +30,11 @@ module SendleAPI
29
30
  def child_object_validations
30
31
  if defined?(self.class::CHILD_OBJECT_KEYS_FOR_VALIDATION)
31
32
  self.class::CHILD_OBJECT_KEYS_FOR_VALIDATION.each do |obj|
32
- if !attributes[obj].nil? && !send(obj).valid?
33
- send(obj).errors.messages.each do |msg_key, messages|
34
- messages.each do |message|
35
- errors.add("#{obj}_#{msg_key}".to_sym, message)
36
- end
33
+ next unless !attributes[obj].nil? && !send(obj).valid?
34
+
35
+ send(obj).errors.messages.each do |msg_key, messages|
36
+ messages.each do |message|
37
+ errors.add("#{obj}_#{msg_key}".to_sym, message)
37
38
  end
38
39
  end
39
40
  end
@@ -41,10 +42,9 @@ module SendleAPI
41
42
  end
42
43
 
43
44
  class << self
44
-
45
45
  def set_site
46
46
  self.site = if SendleAPI.config.testing?
47
- "https://#{basic_auth_details}@sandbox.sendle.com"
47
+ "https://#{basic_auth_details}@sandbox.sendle.com"
48
48
  else
49
49
  "https://#{basic_auth_details}@api.sendle.com"
50
50
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Contact < Base
3
5
  include NotSaveable
@@ -12,4 +14,4 @@ module SendleAPI
12
14
 
13
15
  FIELDS = [:name, :phone, :company]
14
16
  end
15
- end
17
+ end
@@ -1,4 +1,6 @@
1
- require 'digest/sha1'
1
+ # frozen_string_literal: true
2
+
3
+ require "digest/sha1"
2
4
 
3
5
  module SendleAPI
4
6
  class Order < Base
@@ -8,7 +10,7 @@ module SendleAPI
8
10
  has_one :receiver, class_name: Receiver
9
11
 
10
12
  validates :description, :weight, :sender, :receiver, presence: true
11
- validates :first_mile_option, inclusion: { in: ["pickup", "drop off"]}
13
+ validates :first_mile_option, inclusion: { in: ["pickup", "drop off"] }
12
14
 
13
15
  DEFAULT_ATTRS = {
14
16
  pickup_date: nil,
@@ -20,7 +22,7 @@ module SendleAPI
20
22
  weight: Weight.new,
21
23
  volume: Volume.new,
22
24
  sender: Sender.new,
23
- receiver: Receiver.new
25
+ receiver: Receiver.new,
24
26
  }
25
27
 
26
28
  CHILD_OBJECT_KEYS_FOR_VALIDATION = [:weight, :volume, :sender, :receiver]
@@ -47,8 +49,7 @@ module SendleAPI
47
49
  end
48
50
 
49
51
  def set_idempotency_key_header
50
- self.class.headers.merge!("Idempotency-Key": Digest::SHA1.hexdigest(self.encode))
52
+ self.class.headers.merge!("Idempotency-Key": Digest::SHA1.hexdigest(encode))
51
53
  end
52
-
53
54
  end
54
55
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SendleAPI
4
+ class Product < Base
5
+ include NotSaveable
6
+
7
+ self.prefix = "/api/products"
8
+ self.element_name = ""
9
+ end
10
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Receiver < Base
3
5
  include NotSaveable
@@ -10,7 +12,7 @@ module SendleAPI
10
12
  DEFAULT_ATTRS = {
11
13
  contact: Contact.new,
12
14
  address: Address.new,
13
- instructions: ""
15
+ instructions: "",
14
16
  }
15
17
 
16
18
  CHILD_OBJECT_KEYS_FOR_VALIDATION = [:contact, :address]
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Sender < Base
3
5
  include NotSaveable
@@ -7,11 +9,11 @@ module SendleAPI
7
9
 
8
10
  validates :contact, :address, presence: true
9
11
  validate :address_country_valid
10
-
12
+
11
13
  DEFAULT_ATTRS = {
12
14
  contact: Contact.new,
13
15
  address: Address.new,
14
- instructions: ""
16
+ instructions: "",
15
17
  }
16
18
 
17
19
  CHILD_OBJECT_KEYS_FOR_VALIDATION = [:contact, :address]
@@ -20,9 +22,9 @@ module SendleAPI
20
22
 
21
23
  def address_country_valid
22
24
  return unless address
23
-
24
- valid_sender_countries = ['AU', 'US', 'Australia', 'United States']
25
- unless valid_sender_countries.include? address.country
25
+
26
+ valid_sender_countries = ["AU", "US", "Australia", "United States"]
27
+ unless valid_sender_countries.include?(address.country)
26
28
  errors.add(:sender_address_country, "Must be from #{valid_sender_countries}")
27
29
  end
28
30
  end
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Tracking < Base
3
5
  self.prefix = "/api/tracking"
4
6
  self.element_name = ""
5
7
  end
6
- end
8
+ end
@@ -1,11 +1,13 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SendleAPI
2
4
  class Volume < Base
3
5
  include NotSaveable
4
6
 
5
7
  DEFAULT_ATTRS = {
6
8
  value: nil,
7
- units: nil
9
+ units: nil,
8
10
  }
9
- validates :units, inclusion: { in: %w(m3 in3) }, if: -> {value.present?}
11
+ validates :units, inclusion: { in: ["m3", "in3"] }, if: -> { value.present? }
10
12
  end
11
- end
13
+ end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  module SendleAPI
3
4
  class Weight < Base
@@ -5,10 +6,10 @@ module SendleAPI
5
6
 
6
7
  DEFAULT_ATTRS = {
7
8
  value: nil,
8
- units: nil
9
+ units: nil,
9
10
  }
10
11
 
11
12
  validates :value, presence: true
12
- validates :units, inclusion: { in: %w(lb kg) }
13
+ validates :units, inclusion: { in: ["lb", "kg"] }
13
14
  end
14
- end
15
+ end
@@ -1,3 +1,3 @@
1
1
  module SendleAPI
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.9"
3
3
  end
data/lib/sendle_api.rb CHANGED
@@ -1,10 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require "sendle_api/version"
2
4
  require "active_resource"
3
5
 
4
6
  module SendleAPI
5
- require "phonelib"
6
- require "countries"
7
-
8
7
  require "sendle_api/configuration"
9
8
  require "sendle_api/not_saveable"
10
9
  require "sendle_api/errors"
@@ -19,4 +18,5 @@ module SendleAPI
19
18
  require "sendle_api/resources/volume"
20
19
  require "sendle_api/resources/weight"
21
20
  require "sendle_api/resources/order"
21
+ require "sendle_api/resources/product"
22
22
  end
data/sendle_api.gemspec CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require_relative "lib/sendle_api/version"
2
4
 
3
5
  Gem::Specification.new do |spec|
@@ -20,19 +22,21 @@ Gem::Specification.new do |spec|
20
22
  # Specify which files should be added to the gem when it is released.
21
23
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
24
  spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
26
  end
25
27
  spec.bindir = "exe"
26
28
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
29
  spec.require_paths = ["lib"]
28
30
 
29
- spec.add_dependency "activeresource", "~> 5.0"
30
- spec.add_dependency "countries", "~> 3.0"
31
- spec.add_dependency "phonelib", "~> 0.6"
31
+ spec.add_dependency("activeresource", ">= 4.1.0")
32
32
 
33
- spec.add_development_dependency "rspec", "~> 3.2"
34
- spec.add_development_dependency "dotenv"
35
- spec.add_development_dependency "pry-byebug"
36
- spec.add_development_dependency "pry"
37
- spec.add_development_dependency "guard-rspec"
33
+ spec.add_development_dependency("dotenv")
34
+ spec.add_development_dependency("guard-rspec")
35
+ spec.add_development_dependency("pry")
36
+ spec.add_development_dependency("pry-byebug")
37
+ spec.add_development_dependency("rspec", "~> 3.2")
38
+ spec.add_development_dependency("rubocop")
39
+ spec.add_development_dependency("rubocop-shopify")
40
+ spec.add_development_dependency("zeitwerk", "~> 2.1", ">= 2.1.8")
41
+ spec.metadata["rubygems_mfa_required"] = "true"
38
42
  end
metadata CHANGED
@@ -1,73 +1,73 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sendle_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Chong
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2023-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5.0'
19
+ version: 4.1.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5.0'
26
+ version: 4.1.0
27
27
  - !ruby/object:Gem::Dependency
28
- name: countries
28
+ name: dotenv
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '3.0'
34
- type: :runtime
33
+ version: '0'
34
+ type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '3.0'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: phonelib
42
+ name: guard-rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0.6'
48
- type: :runtime
47
+ version: '0'
48
+ type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0.6'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rspec
56
+ name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: '3.2'
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: '3.2'
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: dotenv
70
+ name: pry-byebug
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ">="
@@ -81,7 +81,21 @@ dependencies:
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
- name: pry-byebug
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rubocop
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
101
  - - ">="
@@ -95,7 +109,7 @@ dependencies:
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
- name: pry
112
+ name: rubocop-shopify
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
115
  - - ">="
@@ -109,20 +123,26 @@ dependencies:
109
123
  - !ruby/object:Gem::Version
110
124
  version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
- name: guard-rspec
126
+ name: zeitwerk
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '2.1'
115
132
  - - ">="
116
133
  - !ruby/object:Gem::Version
117
- version: '0'
134
+ version: 2.1.8
118
135
  type: :development
119
136
  prerelease: false
120
137
  version_requirements: !ruby/object:Gem::Requirement
121
138
  requirements:
139
+ - - "~>"
140
+ - !ruby/object:Gem::Version
141
+ version: '2.1'
122
142
  - - ">="
123
143
  - !ruby/object:Gem::Version
124
- version: '0'
125
- description:
144
+ version: 2.1.8
145
+ description:
126
146
  email:
127
147
  - andygg1996personal@gmail.com
128
148
  executables: []
@@ -131,6 +151,7 @@ extra_rdoc_files: []
131
151
  files:
132
152
  - ".gitignore"
133
153
  - ".rspec"
154
+ - ".rubocop.yml"
134
155
  - ".travis.yml"
135
156
  - CODE_OF_CONDUCT.md
136
157
  - Gemfile
@@ -150,6 +171,7 @@ files:
150
171
  - lib/sendle_api/resources/base.rb
151
172
  - lib/sendle_api/resources/contact.rb
152
173
  - lib/sendle_api/resources/order.rb
174
+ - lib/sendle_api/resources/product.rb
153
175
  - lib/sendle_api/resources/receiver.rb
154
176
  - lib/sendle_api/resources/sender.rb
155
177
  - lib/sendle_api/resources/tracking.rb
@@ -165,7 +187,8 @@ metadata:
165
187
  homepage_uri: https://github.com/PostCo/sendle_api
166
188
  source_code_uri: https://github.com/PostCo/sendle_api
167
189
  changelog_uri: https://github.com/PostCo/sendle_api/releases
168
- post_install_message:
190
+ rubygems_mfa_required: 'true'
191
+ post_install_message:
169
192
  rdoc_options: []
170
193
  require_paths:
171
194
  - lib
@@ -180,8 +203,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
203
  - !ruby/object:Gem::Version
181
204
  version: '0'
182
205
  requirements: []
183
- rubygems_version: 3.0.3
184
- signing_key:
206
+ rubygems_version: 3.2.33
207
+ signing_key:
185
208
  specification_version: 4
186
209
  summary: Ruby object based Sendle API wrapper.
187
210
  test_files: []