samcart_api 0.2.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/samcart_api/api_request.rb +3 -3
- data/lib/samcart_api/client.rb +2 -2
- data/lib/samcart_api/order.rb +8 -4
- data/lib/samcart_api/paginator.rb +1 -1
- data/lib/samcart_api/product.rb +4 -4
- data/lib/samcart_api/samcart_object.rb +4 -1
- data/lib/samcart_api/version.rb +5 -0
- data/lib/samcart_api.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3b46630dcf4afb835065d0ac482989a60d029a88573138006787dbf1b1fa4fc2
|
4
|
+
data.tar.gz: 7104d2969a0f4e98263f6d84ee2e3d6f8b1208add3d45ce3d1a103ba4b0415cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d360a67d1037e3585ed0b26c4e41c890dc04cff07c98937efd60207bf847be9d087ab346cafd149013889af001f4e02e6a08c41947d1c450e9f7af7ebc77641c
|
7
|
+
data.tar.gz: 7d5b39108e8d9dbde7fb0d782342ea468196d432a9836f618b3dd0963635f2809c64cf30d0dc4c9a3ae21fa47d0545ae02b51d47494ce029d29b72ba68d7d242
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module SamcartAPI
|
4
4
|
class ApiRequest
|
5
5
|
RETRY_ATTEMPTS = 3
|
6
6
|
|
@@ -9,7 +9,7 @@ module SamcartApi
|
|
9
9
|
@path = path
|
10
10
|
@params = params
|
11
11
|
@api_key = api_key
|
12
|
-
@version =
|
12
|
+
@version = SamcartAPI.configuration.version
|
13
13
|
end
|
14
14
|
|
15
15
|
def perform
|
@@ -56,7 +56,7 @@ module SamcartApi
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def connection
|
59
|
-
@connection ||= Faraday.new(url:
|
59
|
+
@connection ||= Faraday.new(url: SamcartAPI.configuration.api_url) do |conn|
|
60
60
|
conn.response :json
|
61
61
|
conn.adapter Faraday.default_adapter
|
62
62
|
end
|
data/lib/samcart_api/client.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module SamcartAPI
|
4
4
|
# Client for interacting with the SamCart API
|
5
5
|
class Client
|
6
6
|
def initialize(api_key = nil)
|
7
|
-
@api_key = api_key ||
|
7
|
+
@api_key = api_key || SamcartAPI.configuration.api_key
|
8
8
|
raise ConfigurationError, 'API key is required' unless @api_key
|
9
9
|
end
|
10
10
|
|
data/lib/samcart_api/order.rb
CHANGED
@@ -1,22 +1,26 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module SamcartAPI
|
4
4
|
class Order
|
5
5
|
RESOURCE_PATH = '/orders'
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def find(id)
|
9
9
|
order = client.get("#{RESOURCE_PATH}/#{id}")
|
10
|
-
|
10
|
+
SamcartAPI::SamcartObject.new(order)
|
11
11
|
end
|
12
12
|
|
13
13
|
def client
|
14
|
-
|
14
|
+
SamcartAPI::Client.new
|
15
15
|
end
|
16
16
|
|
17
17
|
def all(filters: {}, limit: 100)
|
18
18
|
params = filters.merge(limit:)
|
19
|
-
|
19
|
+
SamcartAPI::Paginator.new(client, RESOURCE_PATH, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def charges(order_id)
|
23
|
+
client.get("#{RESOURCE_PATH}/#{order_id}/charges")
|
20
24
|
end
|
21
25
|
end
|
22
26
|
end
|
data/lib/samcart_api/product.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module SamcartAPI
|
4
4
|
class Product
|
5
5
|
RESOURCE_PATH = '/products'
|
6
6
|
|
7
7
|
class << self
|
8
8
|
def find(id)
|
9
9
|
product = client.get("#{RESOURCE_PATH}/#{id}")
|
10
|
-
|
10
|
+
SamcartAPI::SamcartObject.new(product)
|
11
11
|
end
|
12
12
|
|
13
13
|
def client
|
14
|
-
|
14
|
+
SamcartAPI::Client.new
|
15
15
|
end
|
16
16
|
|
17
17
|
def all(filters: {}, limit: 100)
|
18
18
|
params = filters.merge(limit:)
|
19
19
|
|
20
|
-
|
20
|
+
SamcartAPI::Paginator.new(client, RESOURCE_PATH, params)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module SamcartAPI
|
4
4
|
class SamcartObject
|
5
5
|
def initialize(attributes = {})
|
6
6
|
@attributes = attributes
|
@@ -12,6 +12,9 @@ module SamcartApi
|
|
12
12
|
|
13
13
|
def method_missing(method_name, *args)
|
14
14
|
if @attributes.key?(method_name.to_s)
|
15
|
+
|
16
|
+
warn '[DEPRECATION] Dot notation (.) is deprecated and ' \
|
17
|
+
"will be removed in the next major version. Use hash access ['#{method_name}'] instead."
|
15
18
|
@attributes[method_name.to_s]
|
16
19
|
else
|
17
20
|
super
|
data/lib/samcart_api.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: samcart_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olumuyiwa Osiname
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/samcart_api/paginator.rb
|
124
124
|
- lib/samcart_api/product.rb
|
125
125
|
- lib/samcart_api/samcart_object.rb
|
126
|
+
- lib/samcart_api/version.rb
|
126
127
|
homepage: https://github.com/oluosiname/samcart_api
|
127
128
|
licenses:
|
128
129
|
- MIT
|
@@ -148,5 +149,5 @@ requirements: []
|
|
148
149
|
rubygems_version: 3.5.3
|
149
150
|
signing_key:
|
150
151
|
specification_version: 4
|
151
|
-
summary: Ruby
|
152
|
+
summary: Ruby wrapper for the SamCart API
|
152
153
|
test_files: []
|