freckle_io 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +5 -0
  3. data/.env.sample +3 -0
  4. data/.env.test.sample +3 -0
  5. data/.gitignore +5 -0
  6. data/.rubocop.yml +67 -0
  7. data/.travis.yml +20 -0
  8. data/Gemfile +8 -0
  9. data/README.md +95 -0
  10. data/Rakefile +5 -0
  11. data/freckle-io.gemspec +37 -0
  12. data/icon.svg +192 -0
  13. data/lib/freckle_io/authentication.rb +26 -0
  14. data/lib/freckle_io/client/entries.rb +53 -0
  15. data/lib/freckle_io/client/project_groups.rb +36 -0
  16. data/lib/freckle_io/client/projects.rb +42 -0
  17. data/lib/freckle_io/client/tags.rb +33 -0
  18. data/lib/freckle_io/client/users.rb +35 -0
  19. data/lib/freckle_io/configuration.rb +48 -0
  20. data/lib/freckle_io/connection.rb +80 -0
  21. data/lib/freckle_io/errors/configuration.rb +5 -0
  22. data/lib/freckle_io/errors/connection.rb +9 -0
  23. data/lib/freckle_io/errors/params.rb +8 -0
  24. data/lib/freckle_io/paginator.rb +70 -0
  25. data/lib/freckle_io/params.rb +46 -0
  26. data/lib/freckle_io/request/multiple_pages.rb +62 -0
  27. data/lib/freckle_io/request/single_page.rb +73 -0
  28. data/lib/freckle_io/validator/entry.rb +57 -0
  29. data/lib/freckle_io/validator/project.rb +46 -0
  30. data/lib/freckle_io/validator/project_group.rb +30 -0
  31. data/lib/freckle_io/validator/restricted_hash.rb +11 -0
  32. data/lib/freckle_io/validator/tag.rb +30 -0
  33. data/lib/freckle_io/validator/user.rb +43 -0
  34. data/lib/freckle_io/validator/validation.yml +14 -0
  35. data/lib/freckle_io.rb +35 -0
  36. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +48 -0
  37. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/_all/returns_a_entry_for_each_response.yml +48 -0
  38. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_valid_params/params_should_be_valid.yml +48 -0
  39. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Entries/with_configuration/with_validator/call_entry_s_validator.yml +48 -0
  40. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +99 -0
  41. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/_all/returns_a_project_group_for_each_response.yml +99 -0
  42. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_valid_params/params_should_be_valid.yml +48 -0
  43. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_ProjectGroups/with_configuration/with_validator/call_project_group_s_validator.yml +99 -0
  44. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +491 -0
  45. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_all/returns_a_project_for_each_response.yml +491 -0
  46. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_show/get_a_spacific_project.yml +48 -0
  47. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/_show/raw_links_should_be_a_empty_array.yml +48 -0
  48. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_valid_params/params_should_be_valid.yml +48 -0
  49. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Projects/with_configuration/with_validator/call_project_s_validator.yml +491 -0
  50. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +48 -0
  51. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/_all/returns_a_tag_for_each_response.yml +48 -0
  52. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_valid_params/params_should_be_valid.yml +48 -0
  53. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Tags/with_configuration/with_validator/call_tag_s_validator.yml +48 -0
  54. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_all/result_must_be_a_Request_MultiplePages.yml +99 -0
  55. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_all/returns_a_user_for_each_response.yml +99 -0
  56. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_show/get_a_spacific_user.yml +48 -0
  57. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/_show/raw_links_should_be_a_empty_array.yml +48 -0
  58. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_valid_params/params_should_be_valid.yml +48 -0
  59. data/spec/fixtures/vcr_cassettes/FreckleIO_Client_Users/with_configuration/with_validator/call_user_s_validator.yml +99 -0
  60. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_a_valid_response/must_be_a_json_format.yml +51 -0
  61. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_freckle_token_authentication/set_X-FreckleToken.yml +51 -0
  62. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_header/set_user_agent.yml +51 -0
  63. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_invalid_url/raises_a_resource_not_found_error_for_invalid_resource.yml +40 -0
  64. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_page_param/response_must_be_success.yml +51 -0
  65. data/spec/fixtures/vcr_cassettes/FreckleIO_Connection/with_default_configuration/with_per_page_param/response_must_have_per_page_elements.yml +51 -0
  66. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_configuration/_get/returns_an_array_of_faraday_response.yml +99 -0
  67. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_configuration/_get/returns_freckle_default_per_page_elements.yml +99 -0
  68. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_MultiplePages/with_per_page/_get/return_per_page_number_elements.yml +148 -0
  69. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/next_page_should_be_a_SinglePage.yml +99 -0
  70. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/prev_page_should_be_nil.yml +51 -0
  71. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_first/when_get_last_page_from_the_first_page/next_should_be_nil.yml +99 -0
  72. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_get/returns_correct_raw_links_for_the_first_page.yml +51 -0
  73. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/next_page_should_be_nil.yml +99 -0
  74. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/returns_correct_raw_links_for_the_last_page.yml +99 -0
  75. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_last/when_get_prev_page_from_the_last_page/prev_should_be_nil.yml +147 -0
  76. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_next/previous_page_is_a_SinglePage.yml +147 -0
  77. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_next/previous_page_should_be_not_nil.yml +147 -0
  78. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_prev/next_page_is_a_SinglePage.yml +195 -0
  79. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_prev/when_get_prev_page_from_the_first_page/prev_should_be_nil.yml +147 -0
  80. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_total_page/with_first_page/returns_the_range_of_pages.yml +51 -0
  81. data/spec/fixtures/vcr_cassettes/FreckleIO_Request_SinglePage/with_configuration/_total_page/with_next_page/returns_an_empty_array.yml +99 -0
  82. data/spec/freckle_io/client/entries_spec.rb +359 -0
  83. data/spec/freckle_io/client/project_groups_spec.rb +132 -0
  84. data/spec/freckle_io/client/projects_spec.rb +183 -0
  85. data/spec/freckle_io/client/tags_spec.rb +132 -0
  86. data/spec/freckle_io/client/users_spec.rb +150 -0
  87. data/spec/freckle_io/configuration_spec.rb +70 -0
  88. data/spec/freckle_io/connection_spec.rb +116 -0
  89. data/spec/freckle_io/paginator_spec.rb +105 -0
  90. data/spec/freckle_io/params_spec.rb +15 -0
  91. data/spec/freckle_io/request/multiple_pages_spec.rb +39 -0
  92. data/spec/freckle_io/request/single_page_spec.rb +107 -0
  93. data/spec/spec_helper.rb +69 -0
  94. data/spec/support/anonymize/entries.rb +60 -0
  95. data/spec/support/anonymize/project_groups.rb +55 -0
  96. data/spec/support/anonymize/projects.rb +60 -0
  97. data/spec/support/anonymize/tags.rb +47 -0
  98. data/spec/support/anonymize/users.rb +59 -0
  99. data/spec/support/anonymize_interaction.rb +60 -0
  100. data/spec/support/entry_info.rb +19 -0
  101. data/spec/support/project_group_info.rb +13 -0
  102. data/spec/support/project_info.rb +26 -0
  103. data/spec/support/shared/links/raw_links.rb +13 -0
  104. data/spec/support/tag_info.rb +11 -0
  105. data/spec/support/user_info.rb +21 -0
  106. metadata +382 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f1387e11b8c14ae067534e54d5470eae82ef5e510d5a75a830cf6dc9605d09d6
4
+ data.tar.gz: 0565a0f129768034f84d3710bc68b8095203c5de7b96c3d9f5fcc0bf5d5a4d27
5
+ SHA512:
6
+ metadata.gz: f7176e0da91bbb2d138123af6fd79ad9fa27fc9858b6d86cd5173189f62fdad66f94339d3bee9ddb678fc46ad08b7b1c94dd1c38a8dcdfcf41bb2fe67a9faa25
7
+ data.tar.gz: fdd5edd697332843fa57c132ceec901035a13dbe5fdbbfa5cd62e97b544166fc851a37506023c538129ebd9f26a3f6e3aa8166aaca41ea085cd46d0ee6190b56
data/.codeclimate.yml ADDED
@@ -0,0 +1,5 @@
1
+ plugins:
2
+ rubocop:
3
+ enabled: true
4
+ config:
5
+ file: .rubocop.yml
data/.env.sample ADDED
@@ -0,0 +1,3 @@
1
+ FRECKLE_TOKEN={{Insert here the freckle's token API}}
2
+ REAL_FRECKLE_USER_ID={{Insert here a real user id. This variable will use during the test.}}
3
+ FRECKLE_URL={{Insert here an alternative freckle API url}}
data/.env.test.sample ADDED
@@ -0,0 +1,3 @@
1
+ FRECKLE_TOKEN=token
2
+ REAL_FRECKLE_USER_ID=12345
3
+ FRECKLE_URL=https://example.com
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ .env.*
2
+ !.env.*.sample
3
+ *.gem
4
+ Gemfile.lock
5
+ /coverage/
data/.rubocop.yml ADDED
@@ -0,0 +1,67 @@
1
+ require: rubocop-rspec
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.3
5
+ Exclude:
6
+ - "bin/**/*"
7
+ - ".bundle/**/*"
8
+ - "bundle/**/*"
9
+ - "db/schema.rb"
10
+ - "node_modules/**/*"
11
+ - "**/*.gemspec"
12
+
13
+ Layout/AlignParameters:
14
+ EnforcedStyle: with_fixed_indentation
15
+ Layout/DotPosition:
16
+ EnforcedStyle: trailing
17
+ Layout/SpaceInsideHashLiteralBraces:
18
+ EnforcedStyle: no_space
19
+
20
+ Metrics/BlockLength:
21
+ ExcludedMethods:
22
+ - context
23
+ - describe
24
+ - feature
25
+ - it
26
+ - shared_examples
27
+ - shared_examples_for
28
+ - namespace
29
+ - draw
30
+
31
+ Style/ClassAndModuleChildren:
32
+ EnforcedStyle: compact
33
+ Style/Documentation:
34
+ Enabled: false
35
+ Style/FrozenStringLiteralComment:
36
+ Enabled: false
37
+ Style/Lambda:
38
+ EnforcedStyle: literal
39
+ Style/NegatedIf:
40
+ Enabled: false
41
+ Style/PercentLiteralDelimiters:
42
+ Enabled: false
43
+ Style/StringLiterals:
44
+ EnforcedStyle: double_quotes
45
+ Style/SymbolArray:
46
+ Enabled: false
47
+ Style/ClassAndModuleChildren:
48
+ Enabled: false
49
+ Layout/MultilineHashBraceLayout:
50
+ Enabled: false
51
+
52
+ RSpec/DescribeClass:
53
+ Exclude:
54
+ - spec/*
55
+ - spec/features/**/*
56
+ RSpec/LetSetup:
57
+ Enabled: false
58
+ RSpec/MultipleExpectations:
59
+ Exclude:
60
+ - spec/features/**/*
61
+ RSpec/NamedSubject:
62
+ Enabled: false
63
+ RSpec/NotToNot:
64
+ Enabled: false
65
+ RSpec/NestedGroups:
66
+ Enabled: true
67
+ Max: 4
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=d2619c7f36e46d99be646a88bdb206f69c90064f2473bc42665c2e489f9bf987
4
+ language: ruby
5
+ cache: bundler
6
+ rvm:
7
+ - 2.4
8
+ - 2.5
9
+ before_install: gem install bundler -v 1.16.2
10
+ before_script:
11
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12
+ - chmod +x ./cc-test-reporter
13
+ - ./cc-test-reporter before-build
14
+ - cp .env.test.sample .env.test
15
+ scripts:
16
+ - bundle exec rspec spec
17
+ after_script:
18
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
19
+ notifications:
20
+ - false
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem "pry"
7
+ gem "pry-byebug"
8
+ end
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # freckle-io
2
+
3
+ [![Build Status](https://travis-ci.com/sirion1987/freckle-io.svg?branch=master)](https://travis-ci.com/sirion1987/freckle-io)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/051732f42b5e59d60a5a/maintainability)](https://codeclimate.com/github/sirion1987/Freckle-io/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/051732f42b5e59d60a5a/test_coverage)](https://codeclimate.com/github/sirion1987/Freckle-io/test_coverage)
6
+
7
+ Yet another Ruby client for the Freckle API
8
+
9
+ # Usage
10
+
11
+ 1. Configure `.env` file. You must define the `FRECKLE_TOKEN` environment
12
+ variable with your Freckle API token.
13
+
14
+ E.g.
15
+
16
+ ```
17
+ FRECKLE_TOKEN=123921387213987132987
18
+ ```
19
+
20
+ 2. Configure client with:
21
+
22
+ ```ruby
23
+ FreckleIO.configure do |c|
24
+ c.token = ENV["FRECKLE_TOKEN"]
25
+ c.url = ENV["FRECKLE_URL"]
26
+ c.auth_type = :freckle_token
27
+ c.per_page = 20
28
+ c.max_concurrency = 5
29
+ end
30
+ ```
31
+
32
+ You can set:
33
+
34
+ 1. `FRECKLE_URL`: the URL of the Freckle API. The default value
35
+ is `https://api.letsfreckle.com/v2`.
36
+ 2. `auth_type`: the authentication type which will use with the server.
37
+ Currently, the only allowed values is:
38
+ * `:freckle_token`: uses your Freckle API token.
39
+ 3. `per_page`: the number of items included for each page. The default
40
+ value is 30.
41
+ 4. `max_concurrency`: max thread for each requests.
42
+
43
+ ## Example
44
+
45
+ ```ruby
46
+ require 'dotenv'
47
+ require 'freckle-io'
48
+
49
+ FreckleIO.configure do |c|
50
+ c.token = ENV["FRECKLE_TOKEN"]
51
+ c.auth_type = :freckle_token
52
+ c.max_concurrency = 5
53
+ end
54
+
55
+ client_users = FreckleIO::Client::Users.new.all
56
+
57
+ client_users.last_responses.each do |resp|
58
+ resp.body
59
+ end
60
+ ```
61
+
62
+ # Testing
63
+
64
+ The test suite uses the [VCR](https://github.com/vcr/vcr) gem.
65
+
66
+ The contents of the cassettes is anonymized (see spec/spec_helper.rb).
67
+
68
+ ## Regenerating the VCR cassettes
69
+
70
+ Occasionally, it is a good idea to regenerate the cassettes in order to
71
+ do an end-to-end test.
72
+
73
+ Make sure you have correctly set the `.env.test` file. Inside this file
74
+ you must specify the keys:
75
+
76
+ * `FRECKLE_TOKEN`: your Freckle API token;
77
+ * `FRECKLE_URL`: Freckle API url;
78
+ * `REAL_FRECKLE_USER_ID`: a real user id.
79
+
80
+ ```shell
81
+ $ rm -rf spec/fixtures/vcr_cassettes/*
82
+ $ bundle
83
+ $ bundle exec rspec
84
+ ```
85
+
86
+ # Compatibility
87
+
88
+ This client is set for work with the version 2 (v2) of the Freckle API.
89
+
90
+ # Supported Ruby Versions
91
+
92
+ This library is tested against the following Ruby implementations:
93
+
94
+ * Ruby 2.4
95
+ * Ruby 2.5
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
@@ -0,0 +1,37 @@
1
+ lib = File.expand_path("../lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = "freckle_io"
6
+ spec.version = "0.0.3"
7
+ spec.authors = ["Domenico Giuseppe Garofoli"]
8
+ spec.email = ["sirion1987@gmail.com"]
9
+
10
+ spec.summary = "Yet another Ruby client for the Freckle API"
11
+ spec.description = "Yet another Ruby client for the Freckle API"
12
+ spec.homepage = "https://github.com/sirion1987/freckle-io"
13
+ spec.license = "MIT"
14
+ spec.require_path = ["lib"]
15
+
16
+ spec.required_ruby_version = '>= 2.4.0'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0")
19
+ spec.test_files = Dir["spec/**/*.rb"]
20
+
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "coveralls"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "rubocop"
26
+ spec.add_development_dependency "rubocop-rspec"
27
+ spec.add_development_dependency "simplecov"
28
+ spec.add_development_dependency "simplecov-console"
29
+ spec.add_development_dependency "vcr"
30
+ spec.add_development_dependency "webmock"
31
+
32
+ spec.add_runtime_dependency "dotenv"
33
+ spec.add_runtime_dependency "dry-validation"
34
+ spec.add_runtime_dependency "faraday", ">= 0.15.2"
35
+ spec.add_runtime_dependency "faraday_middleware", ">= 0.12"
36
+ spec.add_runtime_dependency "typhoeus"
37
+ end
data/icon.svg ADDED
@@ -0,0 +1,192 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <!-- Created with Inkscape (http://www.inkscape.org/) -->
3
+
4
+ <svg
5
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
6
+ xmlns:cc="http://creativecommons.org/ns#"
7
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
8
+ xmlns:svg="http://www.w3.org/2000/svg"
9
+ xmlns="http://www.w3.org/2000/svg"
10
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
11
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
12
+ width="210mm"
13
+ height="297mm"
14
+ viewBox="0 0 744.09448819 1052.3622047"
15
+ id="svg2"
16
+ version="1.1"
17
+ inkscape:version="0.91 r13725"
18
+ sodipodi:docname="icon .svg">
19
+ <defs
20
+ id="defs4">
21
+ <filter
22
+ inkscape:collect="always"
23
+ style="color-interpolation-filters:sRGB"
24
+ id="filter5884"
25
+ x="-0.044924623"
26
+ width="1.0898492"
27
+ y="-0.090303033"
28
+ height="1.1806061">
29
+ <feGaussianBlur
30
+ inkscape:collect="always"
31
+ stdDeviation="1.8814091"
32
+ id="feGaussianBlur5886" />
33
+ </filter>
34
+ </defs>
35
+ <sodipodi:namedview
36
+ id="base"
37
+ pagecolor="#ffffff"
38
+ bordercolor="#666666"
39
+ borderopacity="1.0"
40
+ inkscape:pageopacity="0.0"
41
+ inkscape:pageshadow="2"
42
+ inkscape:zoom="2.0788"
43
+ inkscape:cx="322.35944"
44
+ inkscape:cy="483.94209"
45
+ inkscape:document-units="px"
46
+ inkscape:current-layer="layer1"
47
+ showgrid="false"
48
+ showguides="true"
49
+ inkscape:guide-bbox="true"
50
+ inkscape:window-width="2560"
51
+ inkscape:window-height="1416"
52
+ inkscape:window-x="0"
53
+ inkscape:window-y="24"
54
+ inkscape:window-maximized="1">
55
+ <sodipodi:guide
56
+ position="138.3909,650.03318"
57
+ orientation="0,1"
58
+ id="guide4136" />
59
+ <sodipodi:guide
60
+ position="99.500027,550.02807"
61
+ orientation="0,1"
62
+ id="guide4138" />
63
+ <sodipodi:guide
64
+ position="249.50768,629.83013"
65
+ orientation="1,0"
66
+ id="guide4140" />
67
+ <sodipodi:guide
68
+ position="350.01786,625.28444"
69
+ orientation="1,0"
70
+ id="guide4142" />
71
+ <sodipodi:guide
72
+ position="300.01531,611.1423"
73
+ orientation="1,0"
74
+ id="guide4144" />
75
+ <sodipodi:guide
76
+ position="300.01531,600.03062"
77
+ orientation="0,1"
78
+ id="guide4146" />
79
+ <sodipodi:guide
80
+ position="173.74624,624.77936"
81
+ orientation="0,1"
82
+ id="guide4148" />
83
+ <sodipodi:guide
84
+ position="207.58635,574.77681"
85
+ orientation="0,1"
86
+ id="guide4150" />
87
+ <sodipodi:guide
88
+ position="274.76149,600.03062"
89
+ orientation="1,0"
90
+ id="guide5932" />
91
+ <sodipodi:guide
92
+ position="324.76405,600.03062"
93
+ orientation="1,0"
94
+ id="guide5934" />
95
+ <sodipodi:guide
96
+ position="274.76149,612.50001"
97
+ orientation="0,1"
98
+ id="guide5936" />
99
+ <sodipodi:guide
100
+ position="262.65153,612.50001"
101
+ orientation="1,0"
102
+ id="guide4158" />
103
+ <sodipodi:guide
104
+ position="274.76149,587.44152"
105
+ orientation="0,1"
106
+ id="guide4160" />
107
+ <sodipodi:guide
108
+ position="300.01531,650.03318"
109
+ orientation="-0.44721366,0.89442716"
110
+ id="guide4164" />
111
+ <sodipodi:guide
112
+ position="350.01786,624.77936"
113
+ orientation="0.44358884,-0.89623041"
114
+ id="guide4166" />
115
+ <sodipodi:guide
116
+ position="350.01786,574.77681"
117
+ orientation="0.44358884,-0.89623041"
118
+ id="guide4168" />
119
+ <sodipodi:guide
120
+ position="248.99231,574.77681"
121
+ orientation="0.43642078,0.89974269"
122
+ id="guide4170" />
123
+ <sodipodi:guide
124
+ position="249.50768,624.77936"
125
+ orientation="0.44001526,0.89799029"
126
+ id="guide4172" />
127
+ <sodipodi:guide
128
+ position="300.01531,650.03318"
129
+ orientation="0.45081658,0.89261661"
130
+ id="guide4174" />
131
+ <sodipodi:guide
132
+ position="274.76149,562.27745"
133
+ orientation="0.43642086,-0.89974265"
134
+ id="guide4180" />
135
+ </sodipodi:namedview>
136
+ <metadata
137
+ id="metadata7">
138
+ <rdf:RDF>
139
+ <cc:Work
140
+ rdf:about="">
141
+ <dc:format>image/svg+xml</dc:format>
142
+ <dc:type
143
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
144
+ </cc:Work>
145
+ </rdf:RDF>
146
+ </metadata>
147
+ <g
148
+ inkscape:label="Livello 1"
149
+ inkscape:groupmode="layer"
150
+ id="layer1">
151
+ <path
152
+ style="fill:none;fill-rule:evenodd;stroke:#ffcc00;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
153
+ d="m 367.12006,444.34163 -12.10996,5.87394 -25.25382,-12.24938 -4.90094,2.30944"
154
+ id="path4182-0"
155
+ inkscape:connector-curvature="0" />
156
+ <path
157
+ style="fill:none;fill-rule:evenodd;stroke:#ffaa00;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
158
+ d="m 367.0279,443.821 -12.10996,5.87394 -25.25382,-12.24938 -4.90094,2.30944"
159
+ id="path4182-3-6"
160
+ inkscape:connector-curvature="0" />
161
+ <path
162
+ style="fill:#806600;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;opacity:1;filter:url(#filter5884)"
163
+ d="m 249.50768,483.58541 50.50763,24.74874 50.00255,-24.74874 -50.00255,-25.25381 z"
164
+ id="path4166"
165
+ inkscape:connector-curvature="0" />
166
+ <path
167
+ style="fill:#ffd42a;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;fill-opacity:1"
168
+ d="m 249.50768,427.58286 50.50763,-25.25382 50.00255,25.25382 -50.00255,24.74874 z"
169
+ id="path4158"
170
+ inkscape:connector-curvature="0" />
171
+ <path
172
+ style="fill:#d4aa00;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
173
+ d="m 249.50768,427.58286 0,50.00255 50.50763,24.74874 0,-50.00255 -50.50763,-24.74874 z"
174
+ id="path4160"
175
+ inkscape:connector-curvature="0" />
176
+ <path
177
+ style="fill:#ffcc00;fill-rule:evenodd;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
178
+ d="m 300.01531,502.33415 50.00255,-24.74874 0,-50.50763 -50.00255,25.25382 0,50.00255 z"
179
+ id="path4164"
180
+ inkscape:connector-curvature="0" />
181
+ <path
182
+ style="fill:none;fill-rule:evenodd;stroke:#ffcc00;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
183
+ d="m 232.49677,460.76496 12.10996,-5.87394 25.25382,12.24938 4.90094,-2.30944"
184
+ id="path4182"
185
+ inkscape:connector-curvature="0" />
186
+ <path
187
+ style="fill:none;fill-rule:evenodd;stroke:#ffaa00;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
188
+ d="m 232.58893,461.28559 12.10996,-5.87394 25.25382,12.24938 4.90094,-2.30944"
189
+ id="path4182-3"
190
+ inkscape:connector-curvature="0" />
191
+ </g>
192
+ </svg>
@@ -0,0 +1,26 @@
1
+ module FreckleIO
2
+ module Authentication
3
+ AUTHENTICATION_TYPE = [
4
+ :freckle_token
5
+ ].freeze
6
+
7
+ def valid_auth?(type)
8
+ AUTHENTICATION_TYPE.include? type
9
+ end
10
+
11
+ def authorize_request(request)
12
+ auth_type = FreckleIO.configuration.auth_type
13
+
14
+ case auth_type
15
+ when :freckle_token
16
+ request.headers["X-FreckleToken"] = token
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def token
23
+ FreckleIO.configuration.token
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,53 @@
1
+ module FreckleIO
2
+ module Client
3
+ class Entries
4
+ ENTRY_ENDPOINT = "/v2/entries".freeze
5
+ ALLOWED_KEYS = %i(
6
+ user_ids
7
+ description
8
+ project_ids
9
+ tag_ids
10
+ tag_filter_type
11
+ invoice_ids
12
+ import_ids
13
+ from
14
+ to
15
+ invoiced
16
+ invoiced_at_from
17
+ invoiced_at_to
18
+ updated_from
19
+ updated_to
20
+ billable
21
+ approved_at_from
22
+ approved_at_to
23
+ approved_by_ids
24
+ per_page
25
+ ).freeze
26
+ VALIDATOR_MODULE = "FreckleIO::Validator::Entry".freeze
27
+
28
+ def all(params = {})
29
+ multiple_pages.get(ENTRY_ENDPOINT, params: entry_params(params))
30
+ end
31
+
32
+ # not implemented
33
+ #
34
+ # def show(id)
35
+ # single_page.get("#{ENTRY_ENDPOINT}/#{id}")
36
+ # end
37
+
38
+ private
39
+
40
+ def multiple_pages
41
+ @multiple_pages ||= Request::MultiplePages.new
42
+ end
43
+
44
+ def entry_params(params)
45
+ @entry_params = Params.new(
46
+ params,
47
+ ALLOWED_KEYS,
48
+ VALIDATOR_MODULE
49
+ ).call
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,36 @@
1
+ module FreckleIO
2
+ module Client
3
+ class ProjectGroups
4
+ PROJECT_GROUPS_ENDPOINT = "/v2/project_groups".freeze
5
+ ALLOWED_KEYS = %i(name project_ids per_page).freeze
6
+ VALIDATOR_MODULE = "FreckleIO::Validator::ProjectGroup".freeze
7
+
8
+ def all(params = {})
9
+ multiple_pages.get(
10
+ PROJECT_GROUPS_ENDPOINT,
11
+ params: project_groups_params(params)
12
+ )
13
+ end
14
+
15
+ # not implemented
16
+ #
17
+ # def show(id)
18
+ # single_page.get("#{PROJECT_GROUPS_ENDPOINT}/#{id}")
19
+ # end
20
+
21
+ private
22
+
23
+ def multiple_pages
24
+ @multiple_pages ||= Request::MultiplePages.new
25
+ end
26
+
27
+ def project_groups_params(params)
28
+ @project_groups_params = Params.new(
29
+ params,
30
+ ALLOWED_KEYS,
31
+ VALIDATOR_MODULE
32
+ ).call
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,42 @@
1
+ module FreckleIO
2
+ module Client
3
+ class Projects
4
+ PROJECT_ENDPOINT = "/v2/projects".freeze
5
+ ALLOWED_KEYS = %i(
6
+ name
7
+ project_group_ids
8
+ billing_increment
9
+ enabled
10
+ billable
11
+ per_page
12
+ ).freeze
13
+ VALIDATOR_MODULE = "FreckleIO::Validator::Project".freeze
14
+
15
+ def all(params = {})
16
+ multiple_pages.get(PROJECT_ENDPOINT, params: project_params(params))
17
+ end
18
+
19
+ def show(id)
20
+ single_page.get("#{PROJECT_ENDPOINT}/#{id}")
21
+ end
22
+
23
+ private
24
+
25
+ def multiple_pages
26
+ @multiple_pages ||= Request::MultiplePages.new
27
+ end
28
+
29
+ def single_page
30
+ @single_page ||= Request::SinglePage.new
31
+ end
32
+
33
+ def project_params(params)
34
+ @project_params = Params.new(
35
+ params,
36
+ ALLOWED_KEYS,
37
+ VALIDATOR_MODULE
38
+ ).call
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,33 @@
1
+ module FreckleIO
2
+ module Client
3
+ class Tags
4
+ TAG_ENDPOINT = "/v2/tags".freeze
5
+ ALLOWED_KEYS = %i(name billable per_page).freeze
6
+ VALIDATOR_MODULE = "FreckleIO::Validator::Tag".freeze
7
+
8
+ def all(params = {})
9
+ multiple_pages.get(TAG_ENDPOINT, params: tag_params(params))
10
+ end
11
+
12
+ # not implemented
13
+ #
14
+ # def show(id)
15
+ # single_page.get("#{TAG_ENDPOINT}/#{id}")
16
+ # end
17
+
18
+ private
19
+
20
+ def multiple_pages
21
+ @multiple_pages ||= Request::MultiplePages.new
22
+ end
23
+
24
+ def tag_params(params)
25
+ @tag_params = Params.new(
26
+ params,
27
+ ALLOWED_KEYS,
28
+ VALIDATOR_MODULE
29
+ ).call
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,35 @@
1
+ module FreckleIO
2
+ module Client
3
+ class Users
4
+ USER_ENDPOINT = "/v2/users".freeze
5
+ ALLOWED_KEYS = %i(name email role state per_page).freeze
6
+ VALIDATOR_MODULE = "FreckleIO::Validator::User".freeze
7
+
8
+ def all(params = {})
9
+ multiple_pages.get(USER_ENDPOINT, params: user_params(params))
10
+ end
11
+
12
+ def show(id)
13
+ single_page.get("#{USER_ENDPOINT}/#{id}")
14
+ end
15
+
16
+ private
17
+
18
+ def multiple_pages
19
+ @multiple_pages ||= Request::MultiplePages.new
20
+ end
21
+
22
+ def single_page
23
+ @single_page ||= Request::SinglePage.new
24
+ end
25
+
26
+ def user_params(params)
27
+ @user_params = Params.new(
28
+ params,
29
+ ALLOWED_KEYS,
30
+ VALIDATOR_MODULE
31
+ ).call
32
+ end
33
+ end
34
+ end
35
+ end