tindie_api 0.1.4 → 0.1.9

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: 112bc88a7cd40d984989ef332c81e0c4c1dfd827e02e5247632955a2c9613678
4
- data.tar.gz: 18e04b2f25f5f385cff25c997a9ee3fa7e7aadf5cc8149bc5378642f7d18e0dc
3
+ metadata.gz: 1779e3faf74733ae9d38c9e079b0cd48580d0b8d4d60524e653930b8bff4ba90
4
+ data.tar.gz: a030c9c6440f8ee5383ed0a9f7d41b1a29c9f569054aaa9d61c3d721df8cb52a
5
5
  SHA512:
6
- metadata.gz: acac5e238775d9444c3c4789fdb81946733093bc49550397fb662cba0b28cccc5dbd7ee6c813ff7aa44ae60281358245fc126cfe90dcc3453ac6f38d7f3763fc
7
- data.tar.gz: be6790c2699cdaf08a104dd1147b0cf93a8ce9c762d2212a1c727dd5920ad60ff3c6d5624dcca29c7a879ef1ab856fca9d63bb4078a0ed66bf5b62d0703683b6
6
+ metadata.gz: 9805356be076b7d086d3ea557401ca2543f198f6ded69c5f858c1367c6620dee0936741e33a2c5c35dfbc22ebffe62b8036e552066fe662a821d0ac25feaccd6
7
+ data.tar.gz: 2d507819ce2ce35d0e910c283d513d04f62269af140bd260eaec0a5eb27311f0a410a327e0ccf07bf8cc2acd28b5be63c24ff010b28800089c4a984f3fe1ff53
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ .env
data/Gemfile CHANGED
@@ -4,3 +4,6 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in tindie_api.gemspec
6
6
  gemspec
7
+
8
+ gem "webmock"
9
+ gem 'dotenv'
data/README.md CHANGED
@@ -1,39 +1,44 @@
1
- # TindieApi
1
+ # tindie_api
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tindie_api`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
3
+ ## Description
8
4
 
5
+ tindie_api is a Ruby gem that provides a convenient interface for interacting with the Tindie API. This library simplifies the process of managing products, orders, and other Tindie-related operations programmatically.
6
+ ### Installation
9
7
  Add this line to your application's Gemfile:
10
-
11
8
  ```ruby
12
9
  gem 'tindie_api'
13
10
  ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
11
+ Then execute:
12
+ ```bash
13
+ bundle install
14
+ ```
19
15
  Or install it yourself as:
16
+ ```bash
17
+ gem install tindie_api
18
+ ```
19
+ ## Usage
20
20
 
21
- $ gem install tindie_api
22
21
 
23
- ## Usage
22
+ Get unshipped orders
23
+ ```ruby
24
24
 
25
- TODO: Write usage instructions here
25
+ get "/orders" do
26
+ @username = ENV['TINDIE_USERNAME']
27
+ @api_key = ENV['TINDIE_API_KEY']
28
+ @api = TindieApi::TindieOrdersAPI.new(@username, @api_key)
26
29
 
27
- ## Development
30
+ # false means unshipped
31
+ orders = @api.get_orders_json(false)
28
32
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
33
+ puts orders.inspect
30
34
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
35
+ erb :orders, locals: { orders: orders }
36
+ end
37
+ ```
32
38
 
33
- ## Contributing
34
39
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/tindie_api.
40
+ ## Examples
36
41
 
37
- ## License
42
+ See this git repo for additional examples
38
43
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
44
+ [spuder/packpoint](https://github.com/spuder/packpoint)
@@ -1,3 +1,3 @@
1
1
  module TindieApi
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.9"
3
3
  end
data/lib/tindie_api.rb CHANGED
@@ -76,8 +76,16 @@ module TindieApi
76
76
  url += "&shipped=#{shipped}" unless shipped.nil?
77
77
  uri = URI(url)
78
78
  response = Net::HTTP.get(uri)
79
+
80
+ if response.nil? || response.empty?
81
+ raise JSON::ParserError, "Empty response from Tindie API"
82
+ end
83
+
79
84
  JSON.parse(response)
80
- end
85
+ rescue JSON::ParserError => e
86
+ puts "Failed to parse JSON: #{response}"
87
+ raise e
88
+ end
81
89
 
82
90
  def get_orders(shipped = nil)
83
91
  raise ArgumentError, "shipped must be true, false, or nil" if !shipped.nil? && ![true, false].include?(shipped)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tindie_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Spencer Owen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-12-17 00:00:00.000000000 Z
11
+ date: 2024-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler