genba-ruby 0.1.1 → 0.1.2

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: 8bf52f9f2f10e5405122d7d9b7080b191450afc3
4
- data.tar.gz: f0e96c8c994f2d712b9aa901f9c49f89d7e34b20
3
+ metadata.gz: 81925f2beb056e852127da29461edcfad3962805
4
+ data.tar.gz: 44fd64012dcffa16aab398a08420034409e6232c
5
5
  SHA512:
6
- metadata.gz: f39428b2a18b6f7e998797a5fbd3be01fbca1852bac0a3c7d6f14f7b4fbfe25a0053139e01c1320222542e00cb1280568e7485c8551685106c5f7214deaca940
7
- data.tar.gz: '08566d8cdee2b7b704ce757bff1fddeffcf757a27d12f6af939938de888a55d0c071596987b107f3d646c7f594ed4dba233b9a69c9fdd43f31c348304a390764'
6
+ metadata.gz: 7ea2816df1be74b883f5ef2c902ded5548dcaaf42ef95d7748a52eba5288958145a701d51e41fbf4a45ab8591ee92e89cec20f51b0ee52c6f36ff2cc084ed3a3
7
+ data.tar.gz: ed295145135bab4463a388298f08fd9f40116ef22782f991994af5a05a755099aa992b6ec339f9b070de45432eb3d9f7371b4692060b8f43514dd98764f5996b
data/Gemfile CHANGED
@@ -5,6 +5,8 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
5
5
  # Specify your gem's dependencies in genba-ruby.gemspec
6
6
  gemspec
7
7
 
8
+ gem 'activemodel', require: 'active_model'
9
+
8
10
  group :development do
9
11
  gem 'rake'
10
12
  gem 'webmock'
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- genba-ruby (0.1.1)
4
+ genba-ruby (0.1.2)
5
5
  oj (~> 2.18)
6
6
  rest-client (~> 2.0)
7
7
  ruby-mcrypt (= 0.2.0)
@@ -9,10 +9,18 @@ PATH
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
+ activemodel (5.2.0)
13
+ activesupport (= 5.2.0)
14
+ activesupport (5.2.0)
15
+ concurrent-ruby (~> 1.0, >= 1.0.2)
16
+ i18n (>= 0.7, < 2)
17
+ minitest (~> 5.1)
18
+ tzinfo (~> 1.1)
12
19
  addressable (2.5.2)
13
20
  public_suffix (>= 2.0.2, < 4.0)
14
21
  byebug (10.0.2)
15
22
  coderay (1.1.2)
23
+ concurrent-ruby (1.0.5)
16
24
  crack (0.4.3)
17
25
  safe_yaml (~> 1.0.0)
18
26
  diff-lcs (1.3)
@@ -21,10 +29,13 @@ GEM
21
29
  hashdiff (0.3.7)
22
30
  http-cookie (1.0.3)
23
31
  domain_name (~> 0.5)
32
+ i18n (1.0.1)
33
+ concurrent-ruby (~> 1.0)
24
34
  method_source (0.9.0)
25
35
  mime-types (3.1)
26
36
  mime-types-data (~> 3.2015)
27
37
  mime-types-data (3.2016.0521)
38
+ minitest (5.11.3)
28
39
  netrc (0.11.0)
29
40
  oj (2.18.5)
30
41
  pry (0.11.3)
@@ -54,6 +65,9 @@ GEM
54
65
  rspec-support (3.7.1)
55
66
  ruby-mcrypt (0.2.0)
56
67
  safe_yaml (1.0.4)
68
+ thread_safe (0.3.6)
69
+ tzinfo (1.2.5)
70
+ thread_safe (~> 0.1)
57
71
  unf (0.1.4)
58
72
  unf_ext
59
73
  unf_ext (0.0.7.5)
@@ -66,6 +80,7 @@ PLATFORMS
66
80
  ruby
67
81
 
68
82
  DEPENDENCIES
83
+ activemodel
69
84
  bundler (~> 1.16)
70
85
  byebug
71
86
  genba-ruby!
data/lib/genba.rb CHANGED
@@ -3,8 +3,10 @@ require 'digest'
3
3
  require 'mcrypt'
4
4
  require 'rest-client'
5
5
  require 'oj'
6
+ require 'active_model'
6
7
 
7
8
  require 'genba/version'
9
+ require 'genba/key_black_list_request'
8
10
  require 'genba/key_report_request'
9
11
  require 'genba/client/keys'
10
12
  require 'genba/client/prices'
@@ -44,11 +44,27 @@ module Genba
44
44
  @client.rest_post_with_token('/keyReport', payload, headers)
45
45
  end
46
46
 
47
+ def black_list(keys = nil, headers = {})
48
+ raise 'Blacklist keys should be array' unless keys.is_a?(Array)
49
+ raise 'Blacklist keys should be a KeyBlackListRequest class' unless key_black_list_request?(keys)
50
+
51
+ keys.each do |k|
52
+ raise k.errors.full_messages.to_s unless k.valid?
53
+ end
54
+
55
+ payload = keys.map(&:to_genba_json_payload)
56
+ @client.rest_post_with_token('/blackListKeys', payload, headers)
57
+ end
58
+
47
59
  private
48
60
 
49
61
  def key_report_request?(keys)
50
62
  (keys.map { |k| k.is_a?(KeyReportRequest) } & [false]).empty?
51
63
  end
64
+
65
+ def key_black_list_request?(keys)
66
+ (keys.map { |k| k.is_a?(KeyBlackListRequest) } & [false]).empty?
67
+ end
52
68
  end
53
69
  end
54
70
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ # keyBlackListRequest
4
+ class KeyBlackListRequest
5
+ include ActiveModel::Validations
6
+ attr_accessor :key_id, :reason_text
7
+
8
+ validates :key_id, presence: true, allow_blank: false
9
+ validates :reason_text, presence: true, allow_blank: false
10
+
11
+ def initialize(key_id, reason_text)
12
+ @key_id = key_id
13
+ @reason_text = reason_text
14
+ end
15
+
16
+ def to_genba_json_payload
17
+ {
18
+ keyId: @key_id,
19
+ reasonText: @reason_text
20
+ }.compact
21
+ end
22
+ end
data/lib/genba/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Genba
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: genba-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dean Lin
@@ -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_black_list_request.rb
123
124
  - lib/genba/key_report_request.rb
124
125
  - lib/genba/version.rb
125
126
  homepage: https://api.genbagames.com/doc/