frilans_finans_api 0.2.1 → 0.4.0

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: 19679e22ae4245c00de09b7c2fd0026de96e5322
4
- data.tar.gz: 99a3330949fefcf96e6d837783df7bb9bf44bd77
3
+ metadata.gz: 6c8f67e590ba957b8e667a3f48d18d77d44ec051
4
+ data.tar.gz: 45fae99718b042d1c9418c7b9e73bcd1677729ac
5
5
  SHA512:
6
- metadata.gz: f0e28fce16907618efa4041d0a7eab65ab8d3067a3a7ff35e4c83bc74805e9e6827c3083f1343eb68327ca34ef866871e2f587b047e54fdcab8f0775115f7d15
7
- data.tar.gz: cb4a7ec556742b317340e81b39aa3673b2e70ce588ab37a9f5eb2defc968712109feebb3b2809fe5b0312fb1a45e893ae0c481786d024752c50aa37dcc48021a
6
+ metadata.gz: 632e7d458891e82f5e9a4aba87581b36a5c8c204a7e274059c5c838e2aae22ac36eb99d2552cf9be7e4ba4f695e71301b8cdd0fc9881bc6fefb91a4157ee9820
7
+ data.tar.gz: a6dbea109dd234f3d90d528a190bcb7f62b319c158f61bcde5151c69b4b9e1c72492ef6491a8b4acd5e0861e13e81c043d58591306399a2909a792dd7774c071
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- # FrilansFinansApi
1
+ # FrilansFinansAPI
2
+
3
+ [![Build Status](https://travis-ci.org/buren/frilans_finans_api.svg?branch=master)](https://travis-ci.org/buren/frilans_finans_api)
2
4
 
3
5
  Interact with Frilans Finans API.
4
6
 
@@ -21,8 +23,8 @@ Or install it yourself as:
21
23
  __Configure__
22
24
 
23
25
  ```ruby
24
- FrilansFinansApi.configure do |config|
25
- config.client_klass = FrilansFinansApi::Client
26
+ FrilansFinansAPI.configure do |config|
27
+ config.client_klass = FrilansFinansAPI::Client
26
28
  config.base_uri = ENV.fetch('FRILANS_FINANS_BASE_URI')
27
29
  config.client_id = ENV.fetch('FRILANS_FINANS_CLIENT_ID')
28
30
  config.client_secret = ENV.fetch('FRILANS_FINANS_CLIENT_SECRET')
@@ -32,7 +34,7 @@ end
32
34
  ## Usage
33
35
 
34
36
  ```ruby
35
- include FrilansFinansApi
37
+ include FrilansFinansAPI
36
38
 
37
39
  # GET /professions?page=1
38
40
  document = Profession.index(page: 1)
@@ -7,7 +7,7 @@ require 'frilans_finans_api/version'
7
7
 
8
8
  Gem::Specification.new do |spec|
9
9
  spec.name = 'frilans_finans_api'
10
- spec.version = FrilansFinansApi::VERSION
10
+ spec.version = FrilansFinansAPI::VERSION
11
11
  spec.authors = ['Jacob Burenstam']
12
12
  spec.email = ['burenstam@gmail.com']
13
13
 
@@ -25,7 +25,7 @@ require 'frilans_finans_api/statuses'
25
25
  require 'frilans_finans_api/nil_logger'
26
26
  require 'frilans_finans_api/nil_event_logger'
27
27
 
28
- module FrilansFinansApi
28
+ module FrilansFinansAPI
29
29
  class << self
30
30
  attr_accessor :config
31
31
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'frilans_finans_api/client/request'
4
4
 
5
- module FrilansFinansApi
5
+ module FrilansFinansAPI
6
6
  class Client
7
7
  attr_reader :request
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'uri'
4
4
 
5
- module FrilansFinansApi
5
+ module FrilansFinansAPI
6
6
  class FixtureClient
7
7
  # NOTE: If this is extracted out of just_match_api, this will need to change
8
8
  BASE_PATH = __dir__ + '/../../../fixtures'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class NilClient
5
5
  HTTP_STATUS = 200
6
6
  NIL_URI = URI('http://example.com')
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'httparty'
4
4
 
5
- module FrilansFinansApi
5
+ module FrilansFinansAPI
6
6
  class Request
7
7
  USER_AGENT = {
8
8
  'User-Agent' => 'FrilansFinansAPI - Ruby client'
@@ -18,11 +18,11 @@ module FrilansFinansApi
18
18
  attr_reader :credentials, :base_uri, :access_token
19
19
 
20
20
  def initialize(base_uri: nil, client_id: nil, client_secret: nil)
21
- @base_uri = base_uri || FrilansFinansApi.config.base_uri
21
+ @base_uri = base_uri || FrilansFinansAPI.config.base_uri
22
22
  @credentials = {
23
23
  grant_type: GRANT_TYPE,
24
- client_id: client_id || FrilansFinansApi.config.client_id,
25
- client_secret: client_secret || FrilansFinansApi.config.client_secret
24
+ client_id: client_id || FrilansFinansAPI.config.client_id,
25
+ client_secret: client_secret || FrilansFinansAPI.config.client_secret
26
26
  }
27
27
  @access_token = nil
28
28
  end
@@ -134,12 +134,12 @@ module FrilansFinansApi
134
134
  "STATUS: #{status}",
135
135
  "BODY: #{body}"
136
136
  ].join(' ')
137
- FrilansFinansApi.config.event_logger.request_event(params: json_params,
137
+ FrilansFinansAPI.config.event_logger.request_event(params: json_params,
138
138
  status: status,
139
139
  verb: verb,
140
140
  uri: uri,
141
141
  body: body)
142
- FrilansFinansApi.config.logger.info log_body
142
+ FrilansFinansAPI.config.logger.info log_body
143
143
  end
144
144
  end
145
145
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'httparty'
4
4
 
5
- module FrilansFinansApi
5
+ module FrilansFinansAPI
6
6
  class Terms
7
7
  USER_URL = 'https://www.frilansfinans.se/just-arrived-employment-agreement/'.freeze
8
8
  COMPANY_USER_URL = 'https://www.frilansfinans.se/just-arrived-consultancy-agreement/'.freeze
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  module Walker
5
5
  def self.included(base)
6
6
  base.extend(ClassMethods)
7
7
  end
8
8
 
9
9
  module ClassMethods
10
- def walk(client: FrilansFinansApi.config.client_klass.new)
10
+ def walk(client: FrilansFinansAPI.config.client_klass.new)
11
11
  current_page = 1
12
12
  total_pages = 2
13
13
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'json'
4
4
 
5
- module FrilansFinansApi
5
+ module FrilansFinansAPI
6
6
  class Document
7
7
  attr_reader :status, :json, :uri
8
8
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class Company
5
- def self.create(attributes:, client: FrilansFinansApi.config.client_klass.new)
5
+ def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
6
6
  response = client.create_company(attributes: attributes)
7
7
  Document.new(response)
8
8
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class Currency
5
5
  include Walker
6
6
 
7
- def self.index(page: 1, client: FrilansFinansApi.config.client_klass.new)
7
+ def self.index(page: 1, client: FrilansFinansAPI.config.client_klass.new)
8
8
  response = client.currencies(page: page)
9
9
  Document.new(response)
10
10
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class EmploymentCertificate
5
- def self.create(attributes:, client: FrilansFinansApi.config.client_klass.new)
5
+ def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
6
6
  client.create_employment_certificate(attributes: attributes)
7
7
  nil
8
8
  end
@@ -1,18 +1,18 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class Invoice
5
- def self.create(attributes:, client: FrilansFinansApi.config.client_klass.new)
5
+ def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
6
6
  response = client.create_invoice(attributes: attributes)
7
7
  Document.new(response)
8
8
  end
9
9
 
10
- def self.show(id:, client: FrilansFinansApi.config.client_klass.new)
10
+ def self.show(id:, client: FrilansFinansAPI.config.client_klass.new)
11
11
  response = client.invoice(id: id)
12
12
  Document.new(response)
13
13
  end
14
14
 
15
- def self.update(id:, attributes:, client: FrilansFinansApi.config.client_klass.new)
15
+ def self.update(id:, attributes:, client: FrilansFinansAPI.config.client_klass.new)
16
16
  response = client.update_invoice(id: id, attributes: attributes)
17
17
  Document.new(response)
18
18
  end
@@ -1,15 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class Profession
5
5
  include Walker
6
6
 
7
- def self.index(page: 1, client: FrilansFinansApi.config.client_klass.new)
7
+ def self.index(page: 1, client: FrilansFinansAPI.config.client_klass.new)
8
8
  response = client.professions(page: page)
9
9
  Document.new(response)
10
10
  end
11
11
 
12
- def self.show(id:, client: FrilansFinansApi.config.client_klass.new)
12
+ def self.show(id:, client: FrilansFinansAPI.config.client_klass.new)
13
13
  response = client.profession(id: id)
14
14
  Document.new(response)
15
15
  end
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class Salary
5
- def self.index(invoice_id:, page: 1, client: FrilansFinansApi.config.client_klass.new)
5
+ def self.index(invoice_id:, page: 1, client: FrilansFinansAPI.config.client_klass.new)
6
6
  response = client.salaries(invoice_id: invoice_id, page: page)
7
7
  Document.new(response)
8
8
  end
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class Tax
5
5
  include Walker
6
6
 
7
- def self.index(page: 1, only_standard: false, client: FrilansFinansApi.config.client_klass.new) # rubocop:disable Metrics/LineLength
7
+ def self.index(page: 1, only_standard: false, client: FrilansFinansAPI.config.client_klass.new) # rubocop:disable Metrics/LineLength
8
8
  response = client.taxes(page: page, only_standard: only_standard)
9
9
  Document.new(response)
10
10
  end
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class User
5
5
  include Walker
6
6
 
7
- def self.create(attributes:, client: FrilansFinansApi.config.client_klass.new)
7
+ def self.create(attributes:, client: FrilansFinansAPI.config.client_klass.new)
8
8
  response = client.create_user(attributes: attributes)
9
9
  Document.new(response)
10
10
  end
11
11
 
12
- def self.update(id:, attributes:, client: FrilansFinansApi.config.client_klass.new)
12
+ def self.update(id:, attributes:, client: FrilansFinansAPI.config.client_klass.new)
13
13
  response = client.update_user(id: id, attributes: attributes)
14
14
  Document.new(response)
15
15
  end
16
16
 
17
- def self.index(page: 1, email: nil, client: FrilansFinansApi.config.client_klass.new)
17
+ def self.index(page: 1, email: nil, client: FrilansFinansAPI.config.client_klass.new)
18
18
  response = client.users(page: page, email: email)
19
19
  Document.new(response)
20
20
  end
21
21
 
22
- def self.show(id:, client: FrilansFinansApi.config.client_klass.new)
22
+ def self.show(id:, client: FrilansFinansAPI.config.client_klass.new)
23
23
  response = client.user(id: id)
24
24
  Document.new(response)
25
25
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class NilEventLogger
5
5
  def request_event(*); end
6
6
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'logger'
4
4
 
5
- module FrilansFinansApi
5
+ module FrilansFinansAPI
6
6
  class NilLogger < ::Logger
7
7
  def initialize(*args); end
8
8
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  module ParseLog
5
5
  class LogRequest
6
6
  attr_reader :uri, :params, :body, :status
@@ -30,7 +30,7 @@ module FrilansFinansApi
30
30
  def self.call(filename)
31
31
  lines = []
32
32
  File.foreach(filename) do |log_line|
33
- next unless log_line.index('[FrilansFinansApi::Request]')
33
+ next unless log_line.index('[FrilansFinansAPI::Request]')
34
34
 
35
35
  # MATCH BODY
36
36
  body_match = 'BODY: '
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  class Resource
5
5
  def initialize(document)
6
6
  @data = document || {}
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  module Statuses
5
5
  module Invoice
6
6
  STATUSES = {
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
3
+ module FrilansFinansAPI
4
4
  module TestHelper
5
5
  module_function
6
6
 
7
7
  def isolate_frilans_finans_client(klass)
8
- before_klass = FrilansFinansApi.config.client_klass
9
- FrilansFinansApi.config.client_klass = klass
8
+ before_klass = FrilansFinansAPI.config.client_klass
9
+ FrilansFinansAPI.config.client_klass = klass
10
10
  result = yield(before_klass)
11
- FrilansFinansApi.config.client_klass = before_klass
11
+ FrilansFinansAPI.config.client_klass = before_klass
12
12
  result
13
13
  end
14
14
 
15
15
  def stub_frilans_finans_auth_request
16
16
  # Stub auth request
17
- base_uri = FrilansFinansApi.config.base_uri
17
+ base_uri = FrilansFinansAPI.config.base_uri
18
18
  headers = { 'User-Agent' => 'FrilansFinansAPI - Ruby client' }
19
19
  body = [
20
20
  'grant_type=client_credentials',
21
- "client_id=#{FrilansFinansApi.config.client_id}",
22
- "client_secret=#{FrilansFinansApi.config.client_secret}"
21
+ "client_id=#{FrilansFinansAPI.config.client_id}",
22
+ "client_secret=#{FrilansFinansAPI.config.client_secret}"
23
23
  ].join('&')
24
24
 
25
25
  response_body = JSON.dump(
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module FrilansFinansApi
4
- VERSION = '0.2.1'.freeze
3
+ module FrilansFinansAPI
4
+ VERSION = '0.4.0'.freeze
5
5
  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.2.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Burenstam