mkmapi 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 +5 -5
- data/Gemfile +1 -2
- data/{README → README.md} +17 -13
- data/lib/mkmapi.rb +9 -11
- data/lib/mkmapi/agent.rb +18 -18
- data/lib/mkmapi/marketplace.rb +8 -9
- data/lib/version.rb +1 -1
- data/mkmapi.gemspec +18 -18
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 9e702399c7d9be2faa2e6179489bf7f439e2794c3f25094f93ca5045adc2cb78
|
4
|
+
data.tar.gz: 5c8cc7c456e543e567bdf25613d9238b54e1fdcaa712e6c3b9b8a170f3f101ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92f214d2b1eada3444eeac0eb9542b7989efad0784d46b37d81eb63294838761509bb0116211a1876dd9c6127dc9a88eaa5b6622eef33785712391b00162232f
|
7
|
+
data.tar.gz: 6bc9d34e7fe407ed6a42f28e78c48790d9a7c49e6fe02d67602cd4d151d18a0e34b81e8fccfff5c8f1ea47571ea824e5561219a81f925a1ac7236605b3f58178
|
data/Gemfile
CHANGED
data/{README → README.md}
RENAMED
@@ -1,16 +1,16 @@
|
|
1
|
-
|
1
|
+
# Mkmapi
|
2
2
|
|
3
|
-
Ruby interface to the
|
3
|
+
Ruby interface to the cardmarket.eu
|
4
4
|
|
5
|
-
|
5
|
+
## Usage
|
6
6
|
|
7
7
|
You'll need an OAuth credentials for a dedicated app from Mkmapi.
|
8
8
|
|
9
|
-
|
9
|
+
**Add to your Gemfile**
|
10
10
|
|
11
|
-
gem '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
|
-
|
28
|
+
## TODO
|
29
29
|
|
30
|
-
*
|
31
|
-
*
|
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
|
-
|
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
|
-
|
48
|
+
## References
|
49
|
+
Cardmarket RESTful API Documentation: https://api.cardmarket.com/ws/documentation/API_2.0:Main_Page
|
49
50
|
|
50
|
-
|
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)
|
data/lib/mkmapi.rb
CHANGED
@@ -1,18 +1,17 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "bundler/setup"
|
2
|
+
require "faraday"
|
3
3
|
|
4
4
|
module Mkmapi
|
5
|
-
|
6
5
|
path = ->(basename) {
|
7
|
-
File.expand_path File.join(
|
6
|
+
File.expand_path File.join("..", "mkmapi", basename), __FILE__
|
8
7
|
}
|
9
|
-
autoload :Agent,
|
10
|
-
autoload :Session,
|
11
|
-
autoload :Base,
|
12
|
-
autoload :Account,
|
13
|
-
autoload :Marketplace,
|
8
|
+
autoload :Agent, path["agent"]
|
9
|
+
autoload :Session, path["session"]
|
10
|
+
autoload :Base, path["base"]
|
11
|
+
autoload :Account, path["account"]
|
12
|
+
autoload :Marketplace, path["marketplace"]
|
14
13
|
|
15
|
-
def self.connect(url =
|
14
|
+
def self.connect(url = "https://api.cardmarket.com/ws/v2.0")
|
16
15
|
@connection = Faraday.new url, ssl: { verify: false } do |faraday|
|
17
16
|
# faraday.response :logger
|
18
17
|
faraday.adapter Faraday.default_adapter
|
@@ -25,5 +24,4 @@ module Mkmapi
|
|
25
24
|
def self.auth(params)
|
26
25
|
Session.new connection, params
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
data/lib/mkmapi/agent.rb
CHANGED
@@ -1,43 +1,43 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "simple_oauth"
|
2
|
+
require "oj"
|
3
3
|
|
4
4
|
module Mkmapi
|
5
5
|
class Agent < Struct.new(:connection, :auth)
|
6
|
-
|
7
6
|
attr_reader :last
|
8
7
|
|
9
|
-
def get(path)
|
10
|
-
process(:get, path)
|
8
|
+
def get(path, query_params = {})
|
9
|
+
process(:get, path, query_params)
|
11
10
|
end
|
12
11
|
|
13
12
|
def put(path, body)
|
14
13
|
raise NotImplementedError
|
15
14
|
end
|
15
|
+
|
16
16
|
def post(path, body)
|
17
17
|
raise NotImplementedError
|
18
18
|
end
|
19
|
+
|
19
20
|
def delete(path)
|
20
21
|
raise NotImplementedError
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def process(method, path, query_params = {})
|
27
|
+
json_path = "output.json/#{path}"
|
28
|
+
endpoint = connection.url_prefix.to_s + "/" + json_path
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
def oauth(method, url, options = {}, query = {})
|
34
|
-
header = SimpleOAuth::Header.new(method, url, options, auth)
|
30
|
+
@last = connection.send(method, json_path, query_params, authorization: oauth(method, endpoint))
|
31
|
+
Oj.load(@last.body)
|
32
|
+
end
|
35
33
|
|
36
|
-
|
37
|
-
|
34
|
+
def oauth(method, url, options = {}, query = {})
|
35
|
+
header = SimpleOAuth::Header.new(method, url, options, auth)
|
38
36
|
|
39
|
-
|
40
|
-
|
37
|
+
signed_attributes = { realm: url }.update(header.signed_attributes)
|
38
|
+
attributes = signed_attributes.map { |(k, v)| %(#{k}="#{v}") }
|
41
39
|
|
40
|
+
"OAuth #{attributes * ", "}"
|
41
|
+
end
|
42
42
|
end
|
43
43
|
end
|
data/lib/mkmapi/marketplace.rb
CHANGED
@@ -4,22 +4,22 @@ require "stringio"
|
|
4
4
|
|
5
5
|
module Mkmapi
|
6
6
|
class Marketplace < Struct.new(:agent)
|
7
|
-
|
8
|
-
|
7
|
+
def priceguide(game_id = 1)
|
8
|
+
# json_data = agent.get("priceguide", { "idGame" => game_id })
|
9
9
|
json_data = agent.get("priceguide")
|
10
10
|
|
11
11
|
if (json_data && json_data["priceguidefile"])
|
12
12
|
data = Base64.decode64(json_data["priceguidefile"])
|
13
13
|
gzip = Zlib::GzipReader.new(StringIO.new(data))
|
14
14
|
|
15
|
-
keys = ["id", "average", "low", "trend", "german_low", "suggested", "foil", "foil_low", "foil_trend", "low_ex" ]
|
15
|
+
keys = ["id", "average", "low", "trend", "german_low", "suggested", "foil", "foil_low", "foil_trend", "low_ex", "avg1", "avg7", "avg30", "foilavg1", "foilavg7", "foilavg30"]
|
16
16
|
skip_first = gzip.readline # Skip the header
|
17
17
|
|
18
18
|
CSV.parse(gzip.read).map do |a|
|
19
19
|
item = keys.zip(a.map(&:to_f))
|
20
20
|
item[0][1] = item[0][1].to_i
|
21
21
|
|
22
|
-
Hash[
|
22
|
+
Hash[item]
|
23
23
|
end
|
24
24
|
end
|
25
25
|
end
|
@@ -31,7 +31,7 @@ module Mkmapi
|
|
31
31
|
data = Base64.decode64(json_data["productsfile"])
|
32
32
|
gzip = Zlib::GzipReader.new(StringIO.new(data))
|
33
33
|
|
34
|
-
keys = ["id", "name", "category_id", "category", "expansion_id", "date_added"
|
34
|
+
keys = ["id", "name", "category_id", "category", "expansion_id", "date_added"]
|
35
35
|
skip_first = gzip.readline # Skip the header
|
36
36
|
|
37
37
|
CSV.parse(gzip.read).map do |a|
|
@@ -40,14 +40,14 @@ module Mkmapi
|
|
40
40
|
item[2][1] = item[2][1].to_i
|
41
41
|
item[4][1] = item[4][1].to_i
|
42
42
|
item[5][1] = item[5][1].to_i
|
43
|
-
Hash[
|
43
|
+
Hash[item]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
def expansions(game_id = 1)
|
49
49
|
agent.get("games/#{game_id}/expansions")["expansion"].
|
50
|
-
each {|g| g["id"] = g.delete("idExpansion") }
|
50
|
+
each { |g| g["id"] = g.delete("idExpansion") }
|
51
51
|
end
|
52
52
|
|
53
53
|
def singles(expansion_id = 1)
|
@@ -56,12 +56,11 @@ module Mkmapi
|
|
56
56
|
|
57
57
|
def games
|
58
58
|
agent.get("games")["game"].
|
59
|
-
each {|g| g["id"] = g.delete("idGame") }
|
59
|
+
each { |g| g["id"] = g.delete("idGame") }
|
60
60
|
end
|
61
61
|
|
62
62
|
def product(product_id)
|
63
63
|
agent.get("products/#{product_id}")["product"]
|
64
64
|
end
|
65
|
-
|
66
65
|
end
|
67
66
|
end
|
data/lib/version.rb
CHANGED
data/mkmapi.gemspec
CHANGED
@@ -1,26 +1,26 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
require File.expand_path(
|
2
|
+
require File.expand_path("../lib/version", __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors
|
6
|
-
gem.email
|
7
|
-
gem.summary
|
8
|
-
gem.description
|
9
|
-
gem.homepage
|
10
|
-
gem.license
|
5
|
+
gem.authors = ["Arjen Brandenburgh"]
|
6
|
+
gem.email = ["arjen.brandenburgh@gmail.com"]
|
7
|
+
gem.summary = "Simple MagicCardMarket API v2.0 (MkmapiAPI) library for Ruby"
|
8
|
+
gem.description = "Simple MagicCardMarket API v2.0 (MkmapiAPI) library for Ruby"
|
9
|
+
gem.homepage = "http://github.com/arjenbrandenburgh/mkmapi"
|
10
|
+
gem.license = "MIT"
|
11
11
|
|
12
|
-
gem.files
|
13
|
-
gem.test_files
|
14
|
-
gem.name
|
12
|
+
gem.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(spec)/}) }
|
13
|
+
gem.test_files = `git ls-files -- test/*`.split("\n")
|
14
|
+
gem.name = "mkmapi"
|
15
15
|
gem.require_paths = ["lib"]
|
16
|
-
gem.version
|
16
|
+
gem.version = Mkmapi::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency
|
19
|
-
gem.add_dependency
|
20
|
-
gem.add_dependency
|
18
|
+
gem.add_dependency "faraday", "~> 1.1.0"
|
19
|
+
gem.add_dependency "oj", "~> 2.18"
|
20
|
+
gem.add_dependency "simple_oauth", "~> 0.3"
|
21
21
|
|
22
|
-
gem.add_development_dependency
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency
|
25
|
-
gem.add_development_dependency
|
22
|
+
gem.add_development_dependency "rspec"
|
23
|
+
gem.add_development_dependency "rdoc"
|
24
|
+
gem.add_development_dependency "bundler"
|
25
|
+
gem.add_development_dependency "simplecov"
|
26
26
|
end
|
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.
|
4
|
+
version: 0.1.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arjen Brandenburgh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-29 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:
|
19
|
+
version: 1.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:
|
26
|
+
version: 1.1.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
|
-
|
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
|