mkmapi 0.1.3 → 0.1.8

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
- SHA1:
3
- metadata.gz: 311c288bbbba90433de0afa24f9cb2c1dbb835e9
4
- data.tar.gz: b005d24ecaf70a1bc9bb6ed8bd30c39c8f711fbd
2
+ SHA256:
3
+ metadata.gz: 60f2fe81fd10630fc9f978545bd3f26eae090537fffb5540c08df5f691e1d398
4
+ data.tar.gz: c0b45b5b5965b46dbdb3b18f36a05870c980dd5848a17895536d7d3a0c11f694
5
5
  SHA512:
6
- metadata.gz: c1dd077af4786a2b0ddb8bb6d7598643ee628cd66dcc7d37750a3d15d13e65ec4b6cd850e74792c81a7531eb23f4042235aa18fd8fc083e03af8681d8788276d
7
- data.tar.gz: d12a097ce7c45f44a033e12d4ca6504b51118993d052e31cc48bc1a3f4b211c8e6aa947522b06a058d374a425012e1bd135862c7a28b1f7326fa698db2672fdd
6
+ metadata.gz: 0f0a8c9d40b3b11a86a8894e88ca3ecc652abe1bc1bfc9488877663cbf3ca25479e5b24ff223769c03939ef5aca62cabdad956f3c02d5bf5c94d17255c07c256
7
+ data.tar.gz: 519623f93e297eacdb5390e4b121461cabf23b74bc4dcad67fda4c54d9d7eabb7872f7b3a48c1b7c63e8991b32682d5338825081bd1e0292dcada37942448093
data/Gemfile CHANGED
@@ -1,9 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "faraday", "~> 0.11.0"
3
+ gem "faraday", "~> 0.15.2"
4
4
  gem "oj", "~> 2.18.3"
5
5
  gem "simple_oauth", "~> 0.3.1"
6
- gem "nokogiri", "~> 1.8.2"
7
6
 
8
7
  group :development do
9
8
  gem "rspec"
@@ -1,16 +1,16 @@
1
- = Mkmapi
1
+ # Mkmapi
2
2
 
3
- Ruby interface to the magiccardmarket.eu API.
3
+ Ruby interface to the cardmarket.eu
4
4
 
5
- == Usage
5
+ ## Usage
6
6
 
7
7
  You'll need an OAuth credentials for a dedicated app from Mkmapi.
8
8
 
9
- Use with bundler
9
+ **Add to your Gemfile**
10
10
 
11
- gem 'mkmapi', github: 'cybey/mkmapi'
11
+ gem 'mkmapi'
12
12
 
13
- Create a session
13
+ **Create a session**
14
14
 
15
15
  session = Mkmapi.auth({
16
16
  consumer_key: "xxxx",
@@ -19,16 +19,16 @@ Create a session
19
19
  token_secret: "xxxx",
20
20
  })
21
21
 
22
- Retrieve your account's data
22
+ **Retrieve your account's data**
23
23
 
24
24
  me = session.account # => Mkmapi::Account
25
25
  me.id # => 1234
26
26
  me.username # => 'your_user_name'
27
27
 
28
- == TODO
28
+ ## TODO
29
29
 
30
- * domain models
31
- * documentation
30
+ * Domain models
31
+ * Documentation
32
32
  * Account Management
33
33
  * Market Place Information (partially)
34
34
  * Order Management
@@ -36,7 +36,7 @@ Retrieve your account's data
36
36
  * Stock Management
37
37
  * Wants List Management
38
38
 
39
- == Contributing to Mkmapi
39
+ ## Contributing to Mkmapi
40
40
 
41
41
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
42
42
  * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
@@ -45,6 +45,10 @@ Retrieve your account's data
45
45
  * Commit and push until you are happy with your contribution.
46
46
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
47
47
 
48
- == Contributors
48
+ ## References
49
+ Cardmarket RESTful API Documentation: https://api.cardmarket.com/ws/documentation/API_2.0:Main_Page
49
50
 
50
- Based on the work done by knaveofdiamonds.
51
+ ## Contributors
52
+
53
+ [<img src="https://github.com/arjenbrandenburgh.png?size=72" alt="arjenbrandenburgh" width="72">](https://github.com/arjenbrandenburgh)
54
+ [<img src="https://github.com/knaveofdiamonds.png?size=72" alt="knaveofdiamonds" width="72">](https://github.com/knaveofdiamonds)
@@ -12,7 +12,7 @@ module Mkmapi
12
12
  autoload :Account, path['account']
13
13
  autoload :Marketplace, path['marketplace']
14
14
 
15
- def self.connect(url = 'https://www.mkmapi.eu/ws/v2.0')
15
+ def self.connect(url = 'https://api.cardmarket.com/ws/v2.0')
16
16
  @connection = Faraday.new url, ssl: { verify: false } do |faraday|
17
17
  # faraday.response :logger
18
18
  faraday.adapter Faraday.default_adapter
@@ -1,25 +1,24 @@
1
- require 'csv'
2
- require 'zlib'
3
- require 'stringio'
1
+ require "csv"
2
+ require "zlib"
3
+ require "stringio"
4
4
 
5
5
  module Mkmapi
6
6
  class Marketplace < Struct.new(:agent)
7
-
8
- def priceguide
9
- json_data = agent.get("priceguide")
7
+ def priceguide(game_id = 1)
8
+ json_data = agent.get("priceguide?idGame=#{game_id}")
10
9
 
11
10
  if (json_data && json_data["priceguidefile"])
12
11
  data = Base64.decode64(json_data["priceguidefile"])
13
12
  gzip = Zlib::GzipReader.new(StringIO.new(data))
14
13
 
15
- keys = ['id', 'average', 'low', 'trend', 'german_low', 'suggested', 'foil', 'foil_low', 'foil_trend', 'low_ex' ]
14
+ keys = ["id", "average", "low", "trend", "german_low", "suggested", "foil", "foil_low", "foil_trend", "low_ex", "avg1", "avg7", "avg30", "foilavg1", "foilavg7", "foilavg30"]
16
15
  skip_first = gzip.readline # Skip the header
17
16
 
18
17
  CSV.parse(gzip.read).map do |a|
19
18
  item = keys.zip(a.map(&:to_f))
20
19
  item[0][1] = item[0][1].to_i
21
20
 
22
- Hash[ item ]
21
+ Hash[item]
23
22
  end
24
23
  end
25
24
  end
@@ -31,7 +30,7 @@ module Mkmapi
31
30
  data = Base64.decode64(json_data["productsfile"])
32
31
  gzip = Zlib::GzipReader.new(StringIO.new(data))
33
32
 
34
- keys = ['id', 'name', 'category_id', 'category', 'expansion_id', 'date_added' ]
33
+ keys = ["id", "name", "category_id", "category", "expansion_id", "date_added"]
35
34
  skip_first = gzip.readline # Skip the header
36
35
 
37
36
  CSV.parse(gzip.read).map do |a|
@@ -40,14 +39,14 @@ module Mkmapi
40
39
  item[2][1] = item[2][1].to_i
41
40
  item[4][1] = item[4][1].to_i
42
41
  item[5][1] = item[5][1].to_i
43
- Hash[ item ]
42
+ Hash[item]
44
43
  end
45
44
  end
46
45
  end
47
46
 
48
47
  def expansions(game_id = 1)
49
- agent.get("games/#{game_id}/expansions")['expansion'].
50
- each {|g| g['id'] = g.delete('idExpansion') }
48
+ agent.get("games/#{game_id}/expansions")["expansion"].
49
+ each { |g| g["id"] = g.delete("idExpansion") }
51
50
  end
52
51
 
53
52
  def singles(expansion_id = 1)
@@ -55,26 +54,12 @@ module Mkmapi
55
54
  end
56
55
 
57
56
  def games
58
- agent.get("games")['game'].
59
- each {|g| g['id'] = g.delete('idGame') }
60
- end
61
-
62
- def card_by_name(name, game_id = 1, language_id = 1)
63
- product(name, game_id, language_id, true)
57
+ agent.get("games")["game"].
58
+ each { |g| g["id"] = g.delete("idGame") }
64
59
  end
65
60
 
66
- def search(name, game_id = 1, language_id = 1)
67
- product(name, game_id, language_id, false)
61
+ def product(product_id)
62
+ agent.get("products/#{product_id}")["product"]
68
63
  end
69
-
70
- private
71
-
72
- def product(name, game_id, language_id, search)
73
- clean_name = URI.escape(name.gsub(/[^a-zA-Z0-9 ]/, '').downcase)
74
- path = ["products", clean_name, game_id, language_id, search].join("/")
75
-
76
- agent.get(path)['product']
77
- end
78
-
79
64
  end
80
65
  end
@@ -1,3 +1,3 @@
1
1
  module Mkmapi
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.8"
3
3
  end
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Mkmapi::VERSION
17
17
 
18
- gem.add_dependency 'faraday', '~> 0.11'
18
+ gem.add_dependency 'faraday', '~> 0.11.0'
19
19
  gem.add_dependency 'oj', '~> 2.18'
20
20
  gem.add_dependency 'simple_oauth', '~> 0.3'
21
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mkmapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arjen Brandenburgh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-15 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.11'
19
+ version: 0.11.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: '0.11'
26
+ version: 0.11.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: oj
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +119,7 @@ files:
119
119
  - ".gitignore"
120
120
  - Gemfile
121
121
  - LICENSE
122
- - README
122
+ - README.md
123
123
  - Rakefile
124
124
  - lib/mkmapi.rb
125
125
  - lib/mkmapi/agent.rb
@@ -147,8 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  - !ruby/object:Gem::Version
148
148
  version: '0'
149
149
  requirements: []
150
- rubyforge_project:
151
- rubygems_version: 2.6.13
150
+ rubygems_version: 3.1.2
152
151
  signing_key:
153
152
  specification_version: 4
154
153
  summary: Simple MagicCardMarket API v2.0 (MkmapiAPI) library for Ruby