genba-ruby 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/genba-ruby.gemspec +2 -1
- data/lib/genba/client/keys.rb +27 -0
- data/lib/genba/client/products.rb +5 -2
- data/lib/genba/client.rb +3 -4
- data/lib/genba/key_report_request.rb +31 -0
- data/lib/genba/version.rb +1 -1
- data/lib/genba.rb +1 -0
- metadata +13 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8bf52f9f2f10e5405122d7d9b7080b191450afc3
|
4
|
+
data.tar.gz: f0e96c8c994f2d712b9aa901f9c49f89d7e34b20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f39428b2a18b6f7e998797a5fbd3be01fbca1852bac0a3c7d6f14f7b4fbfe25a0053139e01c1320222542e00cb1280568e7485c8551685106c5f7214deaca940
|
7
|
+
data.tar.gz: '08566d8cdee2b7b704ce757bff1fddeffcf757a27d12f6af939938de888a55d0c071596987b107f3d646c7f594ed4dba233b9a69c9fdd43f31c348304a390764'
|
data/Gemfile
CHANGED
@@ -12,7 +12,7 @@ group :development do
|
|
12
12
|
platforms :mri do
|
13
13
|
# to avoid problems, bring Byebug in on just versions of Ruby under which
|
14
14
|
# it's known to work well
|
15
|
-
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new(
|
15
|
+
if Gem::Version.new(RUBY_VERSION.dup) >= Gem::Version.new('2.0.0')
|
16
16
|
gem 'byebug'
|
17
17
|
gem 'pry'
|
18
18
|
gem 'pry-byebug'
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Genba Ruby
|
2
2
|
|
3
|
+
[![Build Status](https://travis-ci.org/iscreen/genba-ruby.svg)](https://travis-ci.org/iscreen/genba-ruby)
|
3
4
|
[![CircleCI](https://circleci.com/gh/iscreen/genba-ruby.svg?style=shield)](https://circleci.com/gh/iscreen/genba-ruby)
|
4
5
|
[![Gem Version](https://badge.fury.io/rb/genba-ruby.svg)](https://badge.fury.io/rb/genba-ruby)
|
5
6
|
|
data/genba-ruby.gemspec
CHANGED
@@ -31,8 +31,9 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.require_paths = ['lib']
|
32
32
|
|
33
33
|
spec.add_runtime_dependency 'rest-client', '~> 2.0'
|
34
|
-
spec.add_runtime_dependency 'oj', '~> 2.18'
|
35
34
|
spec.add_runtime_dependency 'ruby-mcrypt', '0.2.0'
|
35
|
+
spec.add_runtime_dependency 'oj', '~> 2.18'
|
36
|
+
|
36
37
|
|
37
38
|
spec.add_development_dependency 'bundler', '~> 1.16'
|
38
39
|
spec.add_development_dependency 'rake', '~> 10.0'
|
data/lib/genba/client/keys.rb
CHANGED
@@ -22,6 +22,33 @@ module Genba
|
|
22
22
|
)
|
23
23
|
@client.rest_get_with_token('/keys', payload, headers)
|
24
24
|
end
|
25
|
+
|
26
|
+
def get_key_code_status(key_code, params = {}, headers = {})
|
27
|
+
payload = params.merge(
|
28
|
+
keyCode: key_code
|
29
|
+
)
|
30
|
+
@client.rest_get_with_token('/keys', payload, headers)
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_key_status(key_id, params = {}, headers = {})
|
34
|
+
payload = params.merge(
|
35
|
+
id: key_id
|
36
|
+
)
|
37
|
+
@client.rest_get_with_token('/keys', payload, headers)
|
38
|
+
end
|
39
|
+
|
40
|
+
def get_report_usage(keys = nil, headers = {})
|
41
|
+
return raise 'ReportUsage keys should be array' unless keys.is_a?(Array)
|
42
|
+
return raise 'ReportUseag keys should be a KeyReportRequest class' unless key_report_request?(keys)
|
43
|
+
payload = keys.map(&:to_genba_json_payload)
|
44
|
+
@client.rest_post_with_token('/keyReport', payload, headers)
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def key_report_request?(keys)
|
50
|
+
(keys.map { |k| k.is_a?(KeyReportRequest) } & [false]).empty?
|
51
|
+
end
|
25
52
|
end
|
26
53
|
end
|
27
54
|
end
|
@@ -12,8 +12,11 @@ module Genba
|
|
12
12
|
@client.rest_get_with_token('/product', params, headers)
|
13
13
|
end
|
14
14
|
|
15
|
-
def get_changes(params = {}, headers = {})
|
16
|
-
|
15
|
+
def get_changes(from_date, params = {}, headers = {})
|
16
|
+
payload = params.merge(
|
17
|
+
fromDate: from_date
|
18
|
+
)
|
19
|
+
@client.rest_get_with_token('/product/changes', payload, headers)
|
17
20
|
end
|
18
21
|
|
19
22
|
def get_removed(params = {}, headers = {})
|
data/lib/genba/client.rb
CHANGED
@@ -40,20 +40,19 @@ module Genba
|
|
40
40
|
genba_headers = token.merge(headers)
|
41
41
|
headers[:params] = query_params unless query_params.empty?
|
42
42
|
response = RestClient.get("#{API_URL}#{path}", genba_headers)
|
43
|
-
from_rest_client_response(response)
|
43
|
+
from_rest_client_response(response)
|
44
44
|
end
|
45
45
|
|
46
46
|
def rest_put_with_token(path, body = {}, headers = {})
|
47
47
|
genba_headers = token.merge(headers)
|
48
48
|
response = RestClient.put("#{API_URL}#{path}", encode_json(body), genba_headers)
|
49
|
-
|
50
|
-
decode_json(response.body) if response.code == 200
|
49
|
+
from_rest_client_response(response)
|
51
50
|
end
|
52
51
|
|
53
52
|
def rest_post_with_token(path, body = {}, headers = {})
|
54
53
|
genba_headers = token.merge(headers)
|
55
54
|
response = RestClient.post("#{API_URL}#{path}", encode_json(body), genba_headers)
|
56
|
-
|
55
|
+
from_rest_client_response(response)
|
57
56
|
end
|
58
57
|
|
59
58
|
def products
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# KeyReportRequest
|
4
|
+
class KeyReportRequest
|
5
|
+
attr_accessor :key, :key_id, :country_iso, :sale_date, :user_ip_address,
|
6
|
+
:e_tailer_buying_price, :e_tailer_buying_price_currency_code,
|
7
|
+
:e_tailer_selling_price_net, :e_tailer_selling_price_gross,
|
8
|
+
:e_tailer_selling_price_currency_code
|
9
|
+
|
10
|
+
def initialize(data = {})
|
11
|
+
@key = data[:key]
|
12
|
+
@key_id = data[:key_id]
|
13
|
+
@country_iso = data[:country_iso]
|
14
|
+
@user_ip_address = data[:user_ip_address]
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_genba_json_payload
|
18
|
+
{
|
19
|
+
key: @key,
|
20
|
+
keyId: @key_id,
|
21
|
+
countryISO: @country_iso,
|
22
|
+
saleDate: @sale_date,
|
23
|
+
userIpAddress: @user_ip_address,
|
24
|
+
ETailerBuyingPrice: @e_tailer_buying_price,
|
25
|
+
ETailerBuyingPriceCurrencyCode: @e_tailer_buying_price_currency_code,
|
26
|
+
ETailerSellingPriceNet: @e_tailer_selling_price_net,
|
27
|
+
ETailerSellingPriceGross: @e_tailer_selling_price_gross,
|
28
|
+
ETailerSellingPriceCurrencyCode: @e_tailer_selling_price_currency_code
|
29
|
+
}.compact
|
30
|
+
end
|
31
|
+
end
|
data/lib/genba/version.rb
CHANGED
data/lib/genba.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: genba-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dean Lin
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|
@@ -25,33 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ruby-mcrypt
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.2.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: oj
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '2.18'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '2.18'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/genba/client/prices.rb
|
121
121
|
- lib/genba/client/products.rb
|
122
122
|
- lib/genba/client/restrictions.rb
|
123
|
+
- lib/genba/key_report_request.rb
|
123
124
|
- lib/genba/version.rb
|
124
125
|
homepage: https://api.genbagames.com/doc/
|
125
126
|
licenses:
|