frilans_finans_api 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +11 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +4 -0
  5. data/Gemfile +6 -0
  6. data/{README.MD → README.md} +0 -0
  7. data/Rakefile +8 -0
  8. data/fixtures/companies_fixture.json +55 -0
  9. data/fixtures/company_fixture.json +18 -0
  10. data/fixtures/company_post_body_fixture.json +13 -0
  11. data/fixtures/company_post_fixture.json +13 -0
  12. data/fixtures/currencies_fixture.json +148 -0
  13. data/fixtures/invoice_fixture.json +11 -0
  14. data/fixtures/invoice_post_body_fixture.json +26 -0
  15. data/fixtures/invoice_post_fixture.json +11 -0
  16. data/fixtures/invoices_fixture.json +111 -0
  17. data/fixtures/profession_fixture.json +14 -0
  18. data/fixtures/professions_fixture.json +150 -0
  19. data/fixtures/salaries_fixture.json +45 -0
  20. data/fixtures/tax_fixture.json +13 -0
  21. data/fixtures/taxes_fixture.json +59 -0
  22. data/fixtures/user_fixture.json +30 -0
  23. data/fixtures/user_post_body_fixture.json +9 -0
  24. data/fixtures/user_post_fixture.json +30 -0
  25. data/fixtures/users_fixture.json +56 -0
  26. data/frilans_finans_api.gemspec +32 -0
  27. data/lib/frilans_finans_api/client/client.rb +88 -0
  28. data/lib/frilans_finans_api/client/fixture_client.rb +83 -0
  29. data/lib/frilans_finans_api/client/nil_client.rb +31 -0
  30. data/lib/frilans_finans_api/client/request.rb +145 -0
  31. data/lib/frilans_finans_api/client/terms.rb +28 -0
  32. data/lib/frilans_finans_api/client/walker.rb +29 -0
  33. data/lib/frilans_finans_api/models/company.rb +10 -0
  34. data/lib/frilans_finans_api/models/currency.rb +12 -0
  35. data/lib/frilans_finans_api/models/employment_certificate.rb +10 -0
  36. data/lib/frilans_finans_api/models/invoice.rb +20 -0
  37. data/lib/frilans_finans_api/models/profession.rb +17 -0
  38. data/lib/frilans_finans_api/models/salary.rb +10 -0
  39. data/lib/frilans_finans_api/models/tax.rb +12 -0
  40. data/lib/frilans_finans_api/models/user.rb +27 -0
  41. data/lib/frilans_finans_api/version.rb +1 -1
  42. data/lib/frilans_finans_api.rb +61 -0
  43. metadata +41 -2
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FrilansFinansApi
4
+ class Invoice
5
+ def self.create(attributes:, client: FrilansFinansApi.config.client_klass.new)
6
+ response = client.create_invoice(attributes: attributes)
7
+ Document.new(response)
8
+ end
9
+
10
+ def self.show(id:, client: FrilansFinansApi.config.client_klass.new)
11
+ response = client.invoice(id: id)
12
+ Document.new(response)
13
+ end
14
+
15
+ def self.update(id:, attributes:, client: FrilansFinansApi.config.client_klass.new)
16
+ response = client.update_invoice(id: id, attributes: attributes)
17
+ Document.new(response)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FrilansFinansApi
4
+ class Profession
5
+ include Walker
6
+
7
+ def self.index(page: 1, client: FrilansFinansApi.config.client_klass.new)
8
+ response = client.professions(page: page)
9
+ Document.new(response)
10
+ end
11
+
12
+ def self.show(id:, client: FrilansFinansApi.config.client_klass.new)
13
+ response = client.profession(id: id)
14
+ Document.new(response)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FrilansFinansApi
4
+ class Salary
5
+ def self.index(invoice_id:, page: 1, client: FrilansFinansApi.config.client_klass.new)
6
+ response = client.salaries(invoice_id: invoice_id, page: page)
7
+ Document.new(response)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FrilansFinansApi
4
+ class Tax
5
+ include Walker
6
+
7
+ def self.index(page: 1, only_standard: false, client: FrilansFinansApi.config.client_klass.new) # rubocop:disable Metrics/LineLength
8
+ response = client.taxes(page: page, only_standard: only_standard)
9
+ Document.new(response)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FrilansFinansApi
4
+ class User
5
+ include Walker
6
+
7
+ def self.create(attributes:, client: FrilansFinansApi.config.client_klass.new)
8
+ response = client.create_user(attributes: attributes)
9
+ Document.new(response)
10
+ end
11
+
12
+ def self.update(id:, attributes:, client: FrilansFinansApi.config.client_klass.new)
13
+ response = client.update_user(id: id, attributes: attributes)
14
+ Document.new(response)
15
+ end
16
+
17
+ def self.index(page: 1, email: nil, client: FrilansFinansApi.config.client_klass.new)
18
+ response = client.users(page: page, email: email)
19
+ Document.new(response)
20
+ end
21
+
22
+ def self.show(id:, client: FrilansFinansApi.config.client_klass.new)
23
+ response = client.user(id: id)
24
+ Document.new(response)
25
+ end
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FrilansFinansApi
4
- VERSION = '0.1.0'.freeze
4
+ VERSION = '0.2.0'.freeze
5
5
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'frilans_finans_api/version'
4
+
5
+ require 'frilans_finans_api/client/fixture_client'
6
+ require 'frilans_finans_api/client/nil_client'
7
+ require 'frilans_finans_api/client/walker'
8
+ require 'frilans_finans_api/client/client'
9
+ require 'frilans_finans_api/client/terms'
10
+
11
+ require 'frilans_finans_api/models/company'
12
+ require 'frilans_finans_api/models/currency'
13
+ require 'frilans_finans_api/models/employment_certificate'
14
+ require 'frilans_finans_api/models/invoice'
15
+ require 'frilans_finans_api/models/profession'
16
+ require 'frilans_finans_api/models/salary'
17
+ require 'frilans_finans_api/models/tax'
18
+ require 'frilans_finans_api/models/user'
19
+
20
+ require 'frilans_finans_api/document'
21
+ require 'frilans_finans_api/resource'
22
+
23
+ require 'frilans_finans_api/statuses'
24
+
25
+ require 'frilans_finans_api/nil_logger'
26
+ require 'frilans_finans_api/nil_event_logger'
27
+
28
+ module FrilansFinansApi
29
+ class << self
30
+ attr_accessor :config
31
+ end
32
+
33
+ def self.configure
34
+ self.config ||= Configuration.new
35
+ block_given? ? yield(config) : config
36
+ end
37
+
38
+ class Configuration
39
+ attr_accessor :client_klass, :base_uri,
40
+ :logger, :event_logger, :base_uri
41
+
42
+ attr_writer :client_id, :client_secret
43
+
44
+ def initialize
45
+ @client_klass = Client
46
+ @client_id = nil
47
+ @client_secret = nil
48
+ @base_uri = 'https://frilansfinans.se/api'
49
+ @logger = NilLogger.new
50
+ @event_logger = NilEventLogger.new
51
+ end
52
+
53
+ def client_id
54
+ @client_id || fail('#client_id must be set')
55
+ end
56
+
57
+ def client_secret
58
+ @client_secret || fail('#client_secret must be set')
59
+ end
60
+ end
61
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frilans_finans_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Burenstam
@@ -87,11 +87,50 @@ executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
89
89
  files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".travis.yml"
93
+ - Gemfile
90
94
  - LICENSE.txt
91
- - README.MD
95
+ - README.md
96
+ - Rakefile
92
97
  - bin/console
93
98
  - bin/setup
99
+ - fixtures/companies_fixture.json
100
+ - fixtures/company_fixture.json
101
+ - fixtures/company_post_body_fixture.json
102
+ - fixtures/company_post_fixture.json
103
+ - fixtures/currencies_fixture.json
104
+ - fixtures/invoice_fixture.json
105
+ - fixtures/invoice_post_body_fixture.json
106
+ - fixtures/invoice_post_fixture.json
107
+ - fixtures/invoices_fixture.json
108
+ - fixtures/profession_fixture.json
109
+ - fixtures/professions_fixture.json
110
+ - fixtures/salaries_fixture.json
111
+ - fixtures/tax_fixture.json
112
+ - fixtures/taxes_fixture.json
113
+ - fixtures/user_fixture.json
114
+ - fixtures/user_post_body_fixture.json
115
+ - fixtures/user_post_fixture.json
116
+ - fixtures/users_fixture.json
117
+ - frilans_finans_api.gemspec
118
+ - lib/frilans_finans_api.rb
119
+ - lib/frilans_finans_api/client/client.rb
120
+ - lib/frilans_finans_api/client/fixture_client.rb
121
+ - lib/frilans_finans_api/client/nil_client.rb
122
+ - lib/frilans_finans_api/client/request.rb
123
+ - lib/frilans_finans_api/client/terms.rb
124
+ - lib/frilans_finans_api/client/walker.rb
94
125
  - lib/frilans_finans_api/document.rb
126
+ - lib/frilans_finans_api/models/company.rb
127
+ - lib/frilans_finans_api/models/currency.rb
128
+ - lib/frilans_finans_api/models/employment_certificate.rb
129
+ - lib/frilans_finans_api/models/invoice.rb
130
+ - lib/frilans_finans_api/models/profession.rb
131
+ - lib/frilans_finans_api/models/salary.rb
132
+ - lib/frilans_finans_api/models/tax.rb
133
+ - lib/frilans_finans_api/models/user.rb
95
134
  - lib/frilans_finans_api/nil_event_logger.rb
96
135
  - lib/frilans_finans_api/nil_logger.rb
97
136
  - lib/frilans_finans_api/parse_log.rb