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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4ffd8d18495a1fee30099a9648b8ca924e248851
4
- data.tar.gz: e95032398e8f2cee3448816b82264f42176d8b58
3
+ metadata.gz: 8bf52f9f2f10e5405122d7d9b7080b191450afc3
4
+ data.tar.gz: f0e96c8c994f2d712b9aa901f9c49f89d7e34b20
5
5
  SHA512:
6
- metadata.gz: 6f2d58be28a3f0590bc9b471249979674d4ff3f46cc4ac34e949f46fe8f8592897b7a0d1663999fe4b402c94db1d6bf58c33cf9fb1d456a2d907909bc581d5fa
7
- data.tar.gz: 66d1a71cb9d926357e3828e54ab72cd23b20c435114db4565e9c4da5704572e5cbc4b9f620be95f49b2e493d92cce7dc4263d7ab240963a8445fbf123da3c098
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("2.0.0")
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- genba-ruby (0.1.0)
4
+ genba-ruby (0.1.1)
5
5
  oj (~> 2.18)
6
6
  rest-client (~> 2.0)
7
7
  ruby-mcrypt (= 0.2.0)
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'
@@ -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
- @client.rest_get_with_token('/product/changes', params, headers)
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) if response.code == 200
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
- decode_json(response.body) if response.code == 201
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
@@ -1,3 +1,3 @@
1
1
  module Genba
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.1.1'.freeze
3
3
  end
data/lib/genba.rb CHANGED
@@ -5,6 +5,7 @@ require 'rest-client'
5
5
  require 'oj'
6
6
 
7
7
  require 'genba/version'
8
+ require 'genba/key_report_request'
8
9
  require 'genba/client/keys'
9
10
  require 'genba/client/prices'
10
11
  require 'genba/client/products'
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.0
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-03 00:00:00.000000000 Z
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: oj
28
+ name: ruby-mcrypt
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: '2.18'
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: '2.18'
40
+ version: 0.2.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: ruby-mcrypt
42
+ name: oj
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.2.0
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: 0.2.0
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: