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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b1bdda072456e66df0b1d954e208a19fe4046ed013c35507ea8d17a91a9919e4
4
- data.tar.gz: 58417c4bc3cda196ca59dc8d99d5ac6ca39f6719037386aa777c1d07c9ea1a68
3
+ metadata.gz: 3b46630dcf4afb835065d0ac482989a60d029a88573138006787dbf1b1fa4fc2
4
+ data.tar.gz: 7104d2969a0f4e98263f6d84ee2e3d6f8b1208add3d45ce3d1a103ba4b0415cb
5
5
  SHA512:
6
- metadata.gz: 9cc6675ff58a9ffa7dff671991e321d60261d4106c5fbf840fac0a349d2d69d372e4f797ca1a1da608affc349347601d765a29f3e61a2b24164984c148bc2588
7
- data.tar.gz: ceb28e4b6a09859b3863f08d45bf680c2045fec382bde8a93a6f87b04bf075928591248f5404e9d4a3c0da24f1e65399378c4985a5b7d67ac4078e40d1cfc826
6
+ metadata.gz: d360a67d1037e3585ed0b26c4e41c890dc04cff07c98937efd60207bf847be9d087ab346cafd149013889af001f4e02e6a08c41947d1c450e9f7af7ebc77641c
7
+ data.tar.gz: 7d5b39108e8d9dbde7fb0d782342ea468196d432a9836f618b3dd0963635f2809c64cf30d0dc4c9a3ae21fa47d0545ae02b51d47494ce029d29b72ba68d7d242
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SamcartApi
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 = SamcartApi.configuration.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: SamcartApi.configuration.api_url) do |conn|
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
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SamcartApi
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 || SamcartApi.configuration.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
 
@@ -1,22 +1,26 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SamcartApi
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
- SamcartApi::SamcartObject.new(order)
10
+ SamcartAPI::SamcartObject.new(order)
11
11
  end
12
12
 
13
13
  def client
14
- SamcartApi::Client.new
14
+ SamcartAPI::Client.new
15
15
  end
16
16
 
17
17
  def all(filters: {}, limit: 100)
18
18
  params = filters.merge(limit:)
19
- SamcartApi::Paginator.new(client, RESOURCE_PATH, params)
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
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SamcartApi
3
+ module SamcartAPI
4
4
  class Paginator
5
5
  def initialize(client, path, params)
6
6
  @client = client
@@ -1,23 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module SamcartApi
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
- SamcartApi::SamcartObject.new(product)
10
+ SamcartAPI::SamcartObject.new(product)
11
11
  end
12
12
 
13
13
  def client
14
- SamcartApi::Client.new
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
- SamcartApi::Paginator.new(client, RESOURCE_PATH, params)
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 SamcartApi
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
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SamcartAPI
4
+ VERSION = '1.0.0'
5
+ end
data/lib/samcart_api.rb CHANGED
@@ -5,7 +5,7 @@ require 'json'
5
5
  require 'active_support'
6
6
  require 'active_support/core_ext'
7
7
 
8
- module SamcartApi
8
+ module SamcartAPI
9
9
  VERSION = '0.1.0'
10
10
 
11
11
  class Error < StandardError; end
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.2.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-03-09 00:00:00.000000000 Z
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 gem for interacting with the SamCart API
152
+ summary: Ruby wrapper for the SamCart API
152
153
  test_files: []