perfect_audit 0.2.3 → 0.3.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
  SHA256:
3
- metadata.gz: 31c210d13c9eec483be8e9dc4278986b816e063628fa9abce7c6b30262ca2b35
4
- data.tar.gz: b1916f4e5bc65ee12a61480c2592ecdc38545864bda953f6a5a63edcc3fc2ed8
3
+ metadata.gz: b2525916f152c32acfdf977f643690ea0c5485ddd61aaf0cc648d70fa8c471df
4
+ data.tar.gz: 79995d6cf94966c52ecd07951224a36e5f77cbcf02edd564ccc39d2c445ec09f
5
5
  SHA512:
6
- metadata.gz: 8f53132ca903a8be131bf574f8c2e08b364cba9910bf6a67daca1e6e928be9b88e2fa7543cedad347d1c13c07eba1d00631eedfd55dd936b0b96849a7a048250
7
- data.tar.gz: 5baf99d2fc678b936fb6191336706396845dd44a39e3cfe78ac32b8548b9901c72b5b153b52b1efe201f2b6475b7f8ec4d457fb539780292e37bd68845fe84b3
6
+ metadata.gz: 1b6e7b7e09e0f97cdb88e86f607b3faaffa0d1ac79041141ef6d549bd86dbaa7a7a017d2860e0f2391345ac0d7018627f89ba8e2f08a51bf8d59a4a9e0e140d1
7
+ data.tar.gz: 9cf768ec14bc3767401b423da3def0969a5e826cc97b6811e1f5dc98b6dcd0c3c72649de40e9494a1530db483f20144e123370d487c844ce41d4ce16a88bc6d4
@@ -0,0 +1,21 @@
1
+ name: RuboCop
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+
9
+ jobs:
10
+ rubocop:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v3
14
+ - uses: ruby/setup-ruby@v1
15
+ with:
16
+ ruby-version: 2.7
17
+ - name: Lint Ruby code with RuboCop
18
+ run: |
19
+ gem install bundler
20
+ bundle install --gemfile gemfiles/rubocop.gemfile --jobs 4 --retry 3
21
+ bundle exec --gemfile gemfiles/rubocop.gemfile rubocop
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+
11
+ *.gem
data/.irbrc CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'pry'
3
5
  Pry.start
data/.rubocop.yml ADDED
@@ -0,0 +1,6 @@
1
+ inherit_gem:
2
+ jetrockets-standard: config/gems.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.7
6
+ NewCops: enable
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.6
data/Gemfile CHANGED
@@ -1,4 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in perfect_audit.gemspec
4
6
  gemspec
7
+
8
+ eval_gemfile 'gemfiles/rubocop.gemfile'
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
3
5
 
4
6
  RSpec::Core::RakeTask.new(:spec)
5
7
 
6
- task :default => :spec
8
+ task default: :spec
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "perfect_audit"
4
+ require 'bundler/setup'
5
+ require 'perfect_audit'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "perfect_audit"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org' do
4
+ gem 'jetrockets-standard', '~> 1.0'
5
+ end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'perfect_audit/api/period'
2
4
 
3
5
  module PerfectAudit
@@ -6,20 +8,22 @@ module PerfectAudit
6
8
 
7
9
  option :pk, as: :id
8
10
  option :book_pk, as: :book_id
9
- option :account_type#, optional: true
10
- option :account_holder#, optional: true
11
- option :account_number#, optional: true
12
- option :holder_zip#, optional: true
13
- option :holder_state#, optional: true
14
- option :holder_city#, optional: true
15
- option :holder_address_1#, optional: true
16
- option :holder_address_2#, optional: true
11
+ option :account_type # , optional: true
12
+ option :account_holder # , optional: true
13
+ option :account_number # , optional: true
14
+ option :holder_zip # , optional: true
15
+ option :holder_state # , optional: true
16
+ option :holder_city # , optional: true
17
+ option :holder_address_1 # , optional: true
18
+ option :holder_address_2 # , optional: true
17
19
  option :name
18
20
  option :periods, as: :_periods
19
21
 
20
22
  def periods
21
23
  _periods.map do |item|
22
- PerfectAudit::Period.new(item.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo})
24
+ PerfectAudit::Period.new(item.each_with_object({}) { |(k, v), memo|
25
+ memo[k.to_sym] = v
26
+ })
23
27
  end
24
28
  end
25
29
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'perfect_audit/api/bank_account'
2
4
  require 'perfect_audit/api/document'
3
5
 
@@ -18,13 +20,17 @@ module PerfectAudit
18
20
 
19
21
  def bank_accounts
20
22
  _bank_accounts.map do |id, params|
21
- PerfectAudit::BankAccount.new(params.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo})
23
+ PerfectAudit::BankAccount.new(params.each_with_object({}) { |(k, v), memo|
24
+ memo[k.to_sym] = v
25
+ })
22
26
  end
23
27
  end
24
28
 
25
29
  def documents
26
30
  _documents.map do |item|
27
- PerfectAudit::Document.new(item.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo})
31
+ PerfectAudit::Document.new(item.each_with_object({}) { |(k, v), memo|
32
+ memo[k.to_sym] = v
33
+ })
28
34
  end
29
35
  end
30
36
 
@@ -41,6 +47,3 @@ module PerfectAudit
41
47
  end
42
48
  end
43
49
  end
44
-
45
-
46
-
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PerfectAudit
2
4
  class Document
3
5
  extend Dry::Initializer
4
6
 
5
- STATUSES = %w(
7
+ STATUSES = %w[
6
8
  queued
7
9
  failed
8
10
  verifying
@@ -10,7 +12,7 @@ module PerfectAudit
10
12
  deleting
11
13
  deleted
12
14
  rejected
13
- )
15
+ ]
14
16
 
15
17
  option :pk, as: :id
16
18
  option :pages
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PerfectAudit
2
4
  class Period
3
5
  extend Dry::Initializer
@@ -11,6 +13,3 @@ module PerfectAudit
11
13
  option :secondary_recon_error_reason
12
14
  end
13
15
  end
14
-
15
-
16
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'perfect_audit/api/book'
2
4
  require 'http/form_data'
3
5
 
@@ -6,11 +8,11 @@ module PerfectAudit
6
8
  include PerfectAudit::AutoInject[:connection]
7
9
  include PerfectAudit::AutoInject[:response_parser]
8
10
 
9
- CREATE_PATH = 'book/add'.freeze
10
- ALL_PATH = 'books'.freeze
11
- FIND_PATH = 'book/info'.freeze
12
- DELETE_PATH = 'book/remove'.freeze
13
- EXCEL_EXPORT_PATH = 'book/export/xlsx/analytics'.freeze
11
+ CREATE_PATH = 'book/add'
12
+ ALL_PATH = 'books'
13
+ FIND_PATH = 'book/info'
14
+ DELETE_PATH = 'book/remove'
15
+ EXCEL_EXPORT_PATH = 'book/export/xlsx/analytics'
14
16
 
15
17
  # Create book in Perfect Audit
16
18
  #
@@ -23,8 +25,7 @@ module PerfectAudit
23
25
  json: {
24
26
  name: name.to_s,
25
27
  is_public: public.to_s
26
- }
27
- )
28
+ })
28
29
 
29
30
  PerfectAudit::Book.new(response_parser.parse(response.body.to_s))
30
31
  end
@@ -36,12 +37,11 @@ module PerfectAudit
36
37
  def all
37
38
  response = connection.get(ALL_PATH)
38
39
 
39
- response_parser.parse(response.body.to_s).map{ |item|
40
+ response_parser.parse(response.body.to_s).map { |item|
40
41
  PerfectAudit::Book.new(item)
41
42
  }
42
43
  end
43
44
 
44
-
45
45
  # Find book in Perfect Audit
46
46
  #
47
47
  # @param id [Integer] ID of book
@@ -51,8 +51,7 @@ module PerfectAudit
51
51
  response = connection.get(FIND_PATH,
52
52
  params: {
53
53
  pk: id.to_s
54
- }
55
- )
54
+ })
56
55
 
57
56
  PerfectAudit::Book.new(response_parser.parse(response.body.to_s))
58
57
  end
@@ -67,8 +66,7 @@ module PerfectAudit
67
66
  response = connection.post(DELETE_PATH,
68
67
  json: {
69
68
  book_id: id
70
- }
71
- )
69
+ })
72
70
 
73
71
  response_parser.parse(response.body.to_s)
74
72
 
@@ -80,8 +78,7 @@ module PerfectAudit
80
78
  response = connection.get(EXCEL_EXPORT_PATH,
81
79
  params: {
82
80
  pk: id.to_s
83
- }
84
- )
81
+ })
85
82
 
86
83
  response.body.to_s
87
84
  end
@@ -91,7 +88,7 @@ module PerfectAudit
91
88
  include PerfectAudit::AutoInject[:connection]
92
89
  include PerfectAudit::AutoInject[:response_parser]
93
90
 
94
- CREATE_PATH = 'book/upload'.freeze
91
+ CREATE_PATH = 'book/upload'
95
92
 
96
93
  def create(book_or_id, file)
97
94
  id = book_or_id.is_a?(PerfectAudit::Book) ? book_or_id.id.to_s : book_or_id.to_s
@@ -100,8 +97,7 @@ module PerfectAudit
100
97
  form: {
101
98
  pk: id,
102
99
  upload: HTTP::FormData::File.new(file)
103
- }
104
- )
100
+ })
105
101
 
106
102
  response_parser.parse(response.body.to_s)
107
103
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry-initializer'
2
4
  require 'http'
3
5
 
@@ -5,17 +7,17 @@ module PerfectAudit
5
7
  class Connection
6
8
  extend Dry::Initializer
7
9
 
8
- BASE_PATH = 'https://api.ocrolus.com/v1/'.freeze
10
+ BASE_PATH = 'https://api.ocrolus.com/v1/'
9
11
 
10
12
  option :api_key
11
13
  option :api_secret
12
14
 
13
15
  def post(path, params = {})
14
- HTTP.basic_auth(:user => api_key, :pass => api_secret).post(url(path), params)
16
+ HTTP.basic_auth(user: api_key, pass: api_secret).post(url(path), params)
15
17
  end
16
18
 
17
19
  def get(path, params = {})
18
- HTTP.basic_auth(:user => api_key, :pass => api_secret).get(url(path), params)
20
+ HTTP.basic_auth(user: api_key, pass: api_secret).get(url(path), params)
19
21
  end
20
22
 
21
23
  private
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PerfectAudit
2
4
  class Error < StandardError
3
5
  attr_reader :code
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ostruct'
2
4
  require 'perfect_audit/error'
3
5
 
@@ -10,10 +12,14 @@ module PerfectAudit
10
12
 
11
13
  case struct.response
12
14
  when Hash
13
- struct.response.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
15
+ struct.response.each_with_object({}) { |(k, v), memo|
16
+ memo[k.to_sym] = v
17
+ }
14
18
  when Array
15
19
  struct.response.map do |item|
16
- item.inject({}){ |memo,(k,v)| memo[k.to_sym] = v; memo }
20
+ item.each_with_object({}) { |(k, v), memo|
21
+ memo[k.to_sym] = v
22
+ }
17
23
  end
18
24
  else
19
25
  struct.response
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module PerfectAudit
2
- VERSION = '0.2.3'.freeze
4
+ VERSION = '0.3.1'
3
5
  end
data/lib/perfect_audit.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'dry-container'
2
4
  require 'dry-auto_inject'
3
5
 
@@ -6,7 +8,6 @@ require 'perfect_audit/response_parser'
6
8
  require 'perfect_audit/version'
7
9
 
8
10
  module PerfectAudit
9
-
10
11
  class << self
11
12
  def configure
12
13
  yield configuration
@@ -26,10 +27,18 @@ module PerfectAudit
26
27
  # PerfectAudit::TransactionsRepository.new
27
28
  # end
28
29
 
30
+ def container
31
+ @container ||= Dry::Container.new
32
+ end
33
+
34
+ def configuration
35
+ @configuration ||= OpenStruct.new
36
+ end
37
+
29
38
  private
30
39
 
31
40
  def register!
32
- connection = PerfectAudit::Connection.new(configuration.to_h)
41
+ connection = PerfectAudit::Connection.new(**configuration.to_h)
33
42
 
34
43
  container.register :connection, -> { connection }
35
44
  container.register :response_parser, -> { PerfectAudit::ResponseParser }
@@ -38,21 +47,7 @@ module PerfectAudit
38
47
 
39
48
  private
40
49
 
41
- @@container = Dry::Container.new
42
-
43
- AutoInject = Dry::AutoInject(@@container)
44
-
45
- def self.container
46
- @@container
47
- end
48
-
49
- def self.container=(v)
50
- @@container = v
51
- end
52
-
53
- def self.configuration
54
- @@configuration ||= OpenStruct.new
55
- end
50
+ AutoInject = Dry::AutoInject(container)
56
51
  end
57
52
 
58
53
  require 'perfect_audit/api/repositories'
@@ -1,25 +1,26 @@
1
- # coding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'perfect_audit/version'
5
6
 
6
7
  Gem::Specification.new do |spec|
7
- spec.name = "perfect_audit"
8
- spec.version = PerfectAudit::VERSION
9
- spec.authors = ["Igor Alexandrov"]
10
- spec.email = ["igor.alexandrov@gmail.com"]
8
+ spec.name = 'perfect_audit'
9
+ spec.version = PerfectAudit::VERSION
10
+ spec.authors = ['Igor Alexandrov']
11
+ spec.email = ['igor.alexandrov@gmail.com']
11
12
 
12
- spec.summary = %q{Perfect Audit API wrapper.}
13
- spec.description = %q{Perfect Audit API wrapper. https://www.ocrolus.com/api-doc/}
14
- spec.homepage = "https://github.com/igor-alexandrov/perfect_audit"
15
- spec.license = "MIT"
13
+ spec.summary = 'Perfect Audit API wrapper.'
14
+ spec.description = 'Perfect Audit API wrapper. https://www.ocrolus.com/api-doc/'
15
+ spec.homepage = 'https://github.com/igor-alexandrov/perfect_audit'
16
+ spec.license = 'MIT'
16
17
 
17
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ["lib"]
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
21
22
 
22
- spec.required_ruby_version = '~> 2.3'
23
+ spec.required_ruby_version = '>= 2.7.0'
23
24
 
24
25
  # a b c d e f g h i j k l m n o p q r s t u v w x y z
25
26
  spec.add_dependency 'dry-auto_inject'
@@ -28,16 +29,15 @@ Gem::Specification.new do |spec|
28
29
  spec.add_dependency 'http'
29
30
  spec.add_dependency 'http-form_data'
30
31
 
31
-
32
- spec.add_development_dependency 'bundler', "~> 1.11"
32
+ spec.add_development_dependency 'bundler', '>= 1.11'
33
33
 
34
34
  spec.add_development_dependency 'factory_bot'
35
35
  spec.add_development_dependency 'faker'
36
36
 
37
37
  spec.add_development_dependency 'pry'
38
38
 
39
- spec.add_development_dependency 'rake', "~> 10.0"
40
- spec.add_development_dependency 'rspec', "~> 3.0"
39
+ spec.add_development_dependency 'rake', '~> 10.0'
40
+ spec.add_development_dependency 'rspec', '~> 3.0'
41
41
  spec.add_development_dependency 'rspec-collection_matchers'
42
42
 
43
43
  spec.add_development_dependency 'simplecov'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perfect_audit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Alexandrov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-08 00:00:00.000000000 Z
11
+ date: 2023-03-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-auto_inject
@@ -84,14 +84,14 @@ dependencies:
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '1.11'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '1.11'
97
97
  - !ruby/object:Gem::Dependency
@@ -227,9 +227,12 @@ executables: []
227
227
  extensions: []
228
228
  extra_rdoc_files: []
229
229
  files:
230
+ - ".github/workflows/rubocop.yml"
230
231
  - ".gitignore"
231
232
  - ".irbrc"
232
233
  - ".rspec"
234
+ - ".rubocop.yml"
235
+ - ".ruby-version"
233
236
  - ".travis.yml"
234
237
  - Gemfile
235
238
  - LICENSE.txt
@@ -237,6 +240,7 @@ files:
237
240
  - Rakefile
238
241
  - bin/console
239
242
  - bin/setup
243
+ - gemfiles/rubocop.gemfile
240
244
  - lib/perfect_audit.rb
241
245
  - lib/perfect_audit/api/bank_account.rb
242
246
  - lib/perfect_audit/api/book.rb
@@ -258,16 +262,16 @@ require_paths:
258
262
  - lib
259
263
  required_ruby_version: !ruby/object:Gem::Requirement
260
264
  requirements:
261
- - - "~>"
265
+ - - ">="
262
266
  - !ruby/object:Gem::Version
263
- version: '2.3'
267
+ version: 2.7.0
264
268
  required_rubygems_version: !ruby/object:Gem::Requirement
265
269
  requirements:
266
270
  - - ">="
267
271
  - !ruby/object:Gem::Version
268
272
  version: '0'
269
273
  requirements: []
270
- rubygems_version: 3.0.6
274
+ rubygems_version: 3.1.6
271
275
  signing_key:
272
276
  specification_version: 4
273
277
  summary: Perfect Audit API wrapper.