rexpense 1.0.0

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 (114) hide show
  1. checksums.yaml +7 -0
  2. data/.codeclimate.yml +22 -0
  3. data/.coveralls.yml +1 -0
  4. data/.gitignore +24 -0
  5. data/.rspec +2 -0
  6. data/.rubocop.yml +54 -0
  7. data/.travis.yml +9 -0
  8. data/CHANGELOG.md +1 -0
  9. data/Gemfile +4 -0
  10. data/Gemfile.lock +97 -0
  11. data/LICENSE.txt +21 -0
  12. data/README.md +195 -0
  13. data/Rakefile +6 -0
  14. data/bin/console +14 -0
  15. data/bin/rspec +21 -0
  16. data/bin/setup +7 -0
  17. data/lib/rexpense/client.rb +39 -0
  18. data/lib/rexpense/configuration.rb +13 -0
  19. data/lib/rexpense/entities/activity.rb +11 -0
  20. data/lib/rexpense/entities/activity_collection.rb +14 -0
  21. data/lib/rexpense/entities/advancement.rb +14 -0
  22. data/lib/rexpense/entities/advancement_collection.rb +14 -0
  23. data/lib/rexpense/entities/advancement_devolution.rb +13 -0
  24. data/lib/rexpense/entities/attachment.rb +13 -0
  25. data/lib/rexpense/entities/attachment_collection.rb +14 -0
  26. data/lib/rexpense/entities/base.rb +9 -0
  27. data/lib/rexpense/entities/collection.rb +65 -0
  28. data/lib/rexpense/entities/comment.rb +13 -0
  29. data/lib/rexpense/entities/comment_collection.rb +14 -0
  30. data/lib/rexpense/entities/expense.rb +22 -0
  31. data/lib/rexpense/entities/expense_collection.rb +14 -0
  32. data/lib/rexpense/entities/membership.rb +10 -0
  33. data/lib/rexpense/entities/membership_collection.rb +14 -0
  34. data/lib/rexpense/entities/organization.rb +14 -0
  35. data/lib/rexpense/entities/organization_collection.rb +14 -0
  36. data/lib/rexpense/entities/pre_expense.rb +17 -0
  37. data/lib/rexpense/entities/pre_expense_collection.rb +14 -0
  38. data/lib/rexpense/entities/reimbursement.rb +14 -0
  39. data/lib/rexpense/entities/reimbursement_collection.rb +14 -0
  40. data/lib/rexpense/entities/tag.rb +8 -0
  41. data/lib/rexpense/entities/tag_collection.rb +14 -0
  42. data/lib/rexpense/entities/user.rb +14 -0
  43. data/lib/rexpense/entities/user_collection.rb +14 -0
  44. data/lib/rexpense/entities/webhook.rb +10 -0
  45. data/lib/rexpense/entities/webhook_collection.rb +14 -0
  46. data/lib/rexpense/exception.rb +11 -0
  47. data/lib/rexpense/http.rb +41 -0
  48. data/lib/rexpense/request.rb +56 -0
  49. data/lib/rexpense/resources/activity.rb +24 -0
  50. data/lib/rexpense/resources/advancement.rb +20 -0
  51. data/lib/rexpense/resources/advancement_devolution.rb +36 -0
  52. data/lib/rexpense/resources/base.rb +52 -0
  53. data/lib/rexpense/resources/expense.rb +39 -0
  54. data/lib/rexpense/resources/nested_endpoints/attachment.rb +48 -0
  55. data/lib/rexpense/resources/nested_endpoints/comment.rb +84 -0
  56. data/lib/rexpense/resources/nested_endpoints/membership.rb +74 -0
  57. data/lib/rexpense/resources/nested_endpoints/participant.rb +43 -0
  58. data/lib/rexpense/resources/organization.rb +31 -0
  59. data/lib/rexpense/resources/pre_expense.rb +56 -0
  60. data/lib/rexpense/resources/reimbursement.rb +20 -0
  61. data/lib/rexpense/resources/resource_base.rb +105 -0
  62. data/lib/rexpense/resources/tag.rb +82 -0
  63. data/lib/rexpense/resources/webhook.rb +82 -0
  64. data/lib/rexpense/response.rb +43 -0
  65. data/lib/rexpense/version.rb +3 -0
  66. data/lib/rexpense.rb +19 -0
  67. data/rexpense.gemspec +48 -0
  68. data/spec/lib/rexpense/client_spec.rb +47 -0
  69. data/spec/lib/rexpense/configuration_spec.rb +26 -0
  70. data/spec/lib/rexpense/entities/activity_collection_spec.rb +5 -0
  71. data/spec/lib/rexpense/entities/activity_spec.rb +9 -0
  72. data/spec/lib/rexpense/entities/advancement_collection_spec.rb +5 -0
  73. data/spec/lib/rexpense/entities/advancement_devolution_spec.rb +9 -0
  74. data/spec/lib/rexpense/entities/advancement_spec.rb +10 -0
  75. data/spec/lib/rexpense/entities/base_spec.rb +28 -0
  76. data/spec/lib/rexpense/entities/collection_spec.rb +70 -0
  77. data/spec/lib/rexpense/entities/comment_collection_spec.rb +5 -0
  78. data/spec/lib/rexpense/entities/comment_spec.rb +10 -0
  79. data/spec/lib/rexpense/entities/expense_collection_spec.rb +5 -0
  80. data/spec/lib/rexpense/entities/expense_spec.rb +14 -0
  81. data/spec/lib/rexpense/entities/membership_collection_spec.rb +5 -0
  82. data/spec/lib/rexpense/entities/membership_spec.rb +7 -0
  83. data/spec/lib/rexpense/entities/organization_collection_spec.rb +5 -0
  84. data/spec/lib/rexpense/entities/organization_spec.rb +8 -0
  85. data/spec/lib/rexpense/entities/pre_expense_collection_spec.rb +5 -0
  86. data/spec/lib/rexpense/entities/pre_expense_spec.rb +10 -0
  87. data/spec/lib/rexpense/entities/reimbursement_collection_spec.rb +5 -0
  88. data/spec/lib/rexpense/entities/reimbursement_spec.rb +10 -0
  89. data/spec/lib/rexpense/entities/user_collection_spec.rb +5 -0
  90. data/spec/lib/rexpense/entities/user_spec.rb +10 -0
  91. data/spec/lib/rexpense/entities/webhook_collection_spec.rb +5 -0
  92. data/spec/lib/rexpense/entities/webhook_spec.rb +7 -0
  93. data/spec/lib/rexpense/http_spec.rb +37 -0
  94. data/spec/lib/rexpense/request_spec.rb +29 -0
  95. data/spec/lib/rexpense/resources/activity_spec.rb +16 -0
  96. data/spec/lib/rexpense/resources/advancement_devolution_spec.rb +29 -0
  97. data/spec/lib/rexpense/resources/advancement_spec.rb +207 -0
  98. data/spec/lib/rexpense/resources/expense_spec.rb +227 -0
  99. data/spec/lib/rexpense/resources/organization_spec.rb +162 -0
  100. data/spec/lib/rexpense/resources/pre_expense_spec.rb +83 -0
  101. data/spec/lib/rexpense/resources/reimbursement_spec.rb +207 -0
  102. data/spec/lib/rexpense/resources/tag_specs.rb +77 -0
  103. data/spec/lib/rexpense/resources/webhook_spec.rb +51 -0
  104. data/spec/lib/rexpense/response_spec.rb +91 -0
  105. data/spec/lib/rexpense_spec.rb +34 -0
  106. data/spec/spec_helper.rb +39 -0
  107. data/spec/support/attachments/logo.png +0 -0
  108. data/spec/support/client.rb +3 -0
  109. data/spec/support/matchers/have_attr_accessor.rb +18 -0
  110. data/spec/support/shared_examples/entity_attributes.rb +9 -0
  111. data/spec/support/shared_examples/entity_collection.rb +19 -0
  112. data/spec/support/shared_examples/http_request_methods.rb +35 -0
  113. data/spec/support/vcr.rb +7 -0
  114. metadata +390 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b1af2d47bc17b54e64a8ba213fde5cc7c40b6f35
4
+ data.tar.gz: 8bf8a3f461624bc05bfbf697f8548a463282acf9
5
+ SHA512:
6
+ metadata.gz: 4f7aa47c7b07b5794b083011d0628448d80ae6b77fcb6796ceae0856061ae36f0ff652e32191d850d1297afbc984aefbfd2953a04de23dbd5bb81afd42382414
7
+ data.tar.gz: 7747b7ba92d585a6a0c5fdce8b8d9d43012569b0df9d856c70ec0aee21f09c8e3286c42042e70682ead815677c3e2ed249ad962a3868597b6a4d645a01be39b8
data/.codeclimate.yml ADDED
@@ -0,0 +1,22 @@
1
+ ---
2
+ engines:
3
+ bundler-audit:
4
+ enabled: true
5
+ duplication:
6
+ enabled: true
7
+ config:
8
+ languages:
9
+ - ruby
10
+ fixme:
11
+ enabled: true
12
+ rubocop:
13
+ enabled: true
14
+ ratings:
15
+ paths:
16
+ - Gemfile.lock
17
+ - "**.rb"
18
+ exclude_paths:
19
+ - spec/
20
+ - coverage/
21
+ - pkg/
22
+ - tmp/
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ .DS_Store
5
+ .bundle
6
+ .config
7
+ .env
8
+ .envrc
9
+ .rspec-local
10
+ .ruby-*
11
+ .rvmrc
12
+ coverage
13
+ InstalledFiles
14
+ lib/bundler/man
15
+ pkg
16
+ rdoc
17
+ test/tmp
18
+ test/version_tmp
19
+ tmp
20
+
21
+ # YARD artifacts
22
+ .yardoc
23
+ _yardoc
24
+ doc/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format progress
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,54 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ Exclude:
4
+ - "rexpense.gemspec"
5
+ - "Gemfile"
6
+
7
+ Metrics/LineLength:
8
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#80-character-limits"
9
+ Max: 120
10
+
11
+ Metrics/BlockLength:
12
+ Enabled: false
13
+ Exclude:
14
+ - "**/*_spec.rb"
15
+
16
+ Metrics/ModuleLength:
17
+ Exclude:
18
+ - "**/*_spec.rb"
19
+
20
+ Style/Alias:
21
+ EnforcedStyle: "prefer_alias_method"
22
+
23
+ Style/AsciiComments:
24
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#english-comments"
25
+ Enabled: false
26
+
27
+ Style/Documentation:
28
+ Enabled: false
29
+
30
+ Style/DotPosition:
31
+ EnforcedStyle: trailing
32
+
33
+ Style/FrozenStringLiteralComment:
34
+ Enabled: false
35
+
36
+ Style/ParallelAssignment:
37
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#parallel-assignment"
38
+ Enabled: false
39
+
40
+ Style/SpaceAroundEqualsInParameterDefault:
41
+ EnforcedStyle: space
42
+
43
+ Style/StringLiterals:
44
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#consistent-string-literals"
45
+ EnforcedStyle: double_quotes
46
+ Style/PercentLiteralDelimiters:
47
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#percent-literal-braces"
48
+ PreferredDelimiters:
49
+ default: ()
50
+ '%i': '[]'
51
+ '%I': '[]'
52
+ '%r': '{}'
53
+ '%w': '[]'
54
+ '%W': '[]'
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.2.0
5
+ - 2.3.4
6
+ script:
7
+ - bundle exec rake --trace spec
8
+ before_install:
9
+ - gem update bundler
data/CHANGELOG.md ADDED
@@ -0,0 +1 @@
1
+ # Changelog
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in myfinance.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,97 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rexpense (1.0.0)
5
+ mime-types (~> 2.99)
6
+ require_all (~> 1.4.0)
7
+ typhoeus (~> 0.8)
8
+ virtus (~> 1.0.5)
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ addressable (2.5.0)
14
+ public_suffix (~> 2.0, >= 2.0.2)
15
+ awesome_print (1.7.0)
16
+ axiom-types (0.1.1)
17
+ descendants_tracker (~> 0.0.4)
18
+ ice_nine (~> 0.11.0)
19
+ thread_safe (~> 0.3, >= 0.3.1)
20
+ codeclimate-test-reporter (0.6.0)
21
+ simplecov (>= 0.7.1, < 1.0.0)
22
+ coderay (1.1.1)
23
+ coercible (1.0.0)
24
+ descendants_tracker (~> 0.0.1)
25
+ crack (0.4.3)
26
+ safe_yaml (~> 1.0.0)
27
+ descendants_tracker (0.0.4)
28
+ thread_safe (~> 0.3, >= 0.3.1)
29
+ diff-lcs (1.3)
30
+ docile (1.1.5)
31
+ equalizer (0.0.11)
32
+ ethon (0.10.1)
33
+ ffi (>= 1.3.0)
34
+ ffi (1.9.18)
35
+ ice_nine (0.11.2)
36
+ json (2.0.3)
37
+ method_source (0.8.2)
38
+ mime-types (2.99.3)
39
+ pry (0.10.4)
40
+ coderay (~> 1.1.0)
41
+ method_source (~> 0.8.1)
42
+ slop (~> 3.4)
43
+ pry-nav (0.2.4)
44
+ pry (>= 0.9.10, < 0.11.0)
45
+ public_suffix (2.0.5)
46
+ rake (10.5.0)
47
+ require_all (1.4.0)
48
+ rspec (3.5.0)
49
+ rspec-core (~> 3.5.0)
50
+ rspec-expectations (~> 3.5.0)
51
+ rspec-mocks (~> 3.5.0)
52
+ rspec-core (3.5.4)
53
+ rspec-support (~> 3.5.0)
54
+ rspec-expectations (3.5.0)
55
+ diff-lcs (>= 1.2.0, < 2.0)
56
+ rspec-support (~> 3.5.0)
57
+ rspec-mocks (3.5.0)
58
+ diff-lcs (>= 1.2.0, < 2.0)
59
+ rspec-support (~> 3.5.0)
60
+ rspec-support (3.5.0)
61
+ safe_yaml (1.0.4)
62
+ simplecov (0.13.0)
63
+ docile (~> 1.1.0)
64
+ json (>= 1.8, < 3)
65
+ simplecov-html (~> 0.10.0)
66
+ simplecov-html (0.10.0)
67
+ slop (3.6.0)
68
+ thread_safe (0.3.6)
69
+ typhoeus (0.8.0)
70
+ ethon (>= 0.8.0)
71
+ vcr (2.9.3)
72
+ virtus (1.0.5)
73
+ axiom-types (~> 0.1)
74
+ coercible (~> 1.0)
75
+ descendants_tracker (~> 0.0, >= 0.0.3)
76
+ equalizer (~> 0.0, >= 0.0.9)
77
+ webmock (1.9.3)
78
+ addressable (>= 2.2.7)
79
+ crack (>= 0.3.2)
80
+
81
+ PLATFORMS
82
+ ruby
83
+
84
+ DEPENDENCIES
85
+ awesome_print (~> 1.1)
86
+ codeclimate-test-reporter (~> 0.4)
87
+ pry (~> 0.9)
88
+ pry-nav (~> 0.2)
89
+ rake (~> 10.0)
90
+ rexpense!
91
+ rspec
92
+ simplecov (~> 0.9)
93
+ vcr (~> 2.4)
94
+ webmock (~> 1.9.3)
95
+
96
+ BUNDLED WITH
97
+ 1.15.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Eduardo Hertz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,195 @@
1
+ # rexpense-client-ruby
2
+
3
+ A Ruby client for the [Rexpense](http://www.rexpense.com) REST API
4
+
5
+ [![Gem version](https://badge.fury.io/rb/rexpense.png)](https://rubygems.org/gems/rexpense)
6
+ [![Build status](https://travis-ci.org/myfreecomm/rexpense-client-ruby.png?branch=master)](https://travis-ci.org/myfreecomm/rexpense-client-ruby)
7
+ [![Test coverage](https://codeclimate.com/github/myfreecomm/rexpense-client-ruby/badges/coverage.svg)](https://codeclimate.com/github/myfreecomm/v-client-ruby)
8
+ [![Code Climate grade](https://codeclimate.com/github/myfreecomm/rexpense-client-ruby.png)](https://codeclimate.com/github/myfreecomm/rexpense-client-ruby)
9
+
10
+ Rexpense API docs: http://developers.rexpense.com
11
+
12
+ ## Installation
13
+
14
+ Add this line to your application's Gemfile:
15
+
16
+ ```ruby
17
+ gem 'rexpense'
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+ Or install it yourself as:
25
+
26
+ $ gem install rexpense
27
+
28
+ ## Configuration
29
+
30
+ Use `Rexpense.configure` to setup your environment:
31
+
32
+ ```ruby
33
+ require 'rexpense'
34
+
35
+ Rexpense.configure do |config|
36
+ config.api_mode = 'production' # To set the rexpense application that will use
37
+ config.version = 'v1' # Current API version
38
+ config.user_agent = 'My App v1.0' # optional, but you should pass a custom user-agent identifying your app
39
+ end
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ ##### Given your token, create an instance of Rexpense::Client, as below:
45
+
46
+ ```ruby
47
+ client = Rexpense.client("YOUR_TOKEN_HERE")
48
+ ```
49
+
50
+ ##### Now you have access to these API endpoints:
51
+
52
+
53
+ ### Available Endpoints
54
+
55
+ - [Advancement Participants](http://developers.rexpense.com/api/v1/advancement_participants/)
56
+ ```ruby
57
+ client.advancements.participants(:advancement_id)
58
+ client.advancements.leave_participant(:advancement_id)
59
+ ```
60
+ - [Reimbursement Participants](http://developers.rexpense.com/api/v1/reimbursement_participants/)
61
+ ```ruby
62
+ client.reimbursements.participants(:reimbursement_id)
63
+ client.reimbursements.leave_participant(:reimbursement_id)
64
+ ```
65
+
66
+ - [Expense Participants](http://developers.rexpense.com/api/v1/expense_participants/)
67
+ ```ruby
68
+ client.expenses.participants(:expense_id)
69
+ client.expenses.leave_participant(:expense_id)
70
+ ```
71
+
72
+ - [Comments](http://developers.rexpense.com/api/v1/comments/)
73
+ ```ruby
74
+ client.advancements.comments(:advancement_id)
75
+ client.advancements.find_comment(:advancement_id, :comment_id)
76
+ client.advancements.create_comment(:advancement_id, params)
77
+ client.advancements.update_comment(:advancement_id, :comment_id, params)
78
+ client.advancements.destroy_comment(:advancement_id, :comment_id)
79
+
80
+ client.reimbursement.comments(:advancement_id)
81
+ client.reimbursement.find_comment(:advancement_id, :comment_id)
82
+ client.reimbursement.create_comment(:advancement_id, params)
83
+ client.reimbursement.update_comment(:advancement_id, :comment_id, params)
84
+ client.reimbursement.destroy_comment(:advancement_id, :comment_id)
85
+
86
+ client.expenses.comments(:advancement_id)
87
+ client.expenses.find_comment(:advancement_id, :comment_id)
88
+ client.expenses.create_comment(:advancement_id, params)
89
+ client.expenses.update_comment(:advancement_id, :comment_id, params)
90
+ client.expenses.destroy_comment(:advancement_id, :comment_id)
91
+ ```
92
+
93
+ - [Activities](http://developers.rexpense.com/api/v1/activities/)
94
+ ```ruby
95
+ client.activitites.find_all
96
+ ```
97
+
98
+ - [Advancements](http://developers.rexpense.com/api/v1/advancements/)
99
+ ```ruby
100
+ client.advancements.find_all
101
+ client.advancements.find(:advancement_id)
102
+ client.advancements.create(params)
103
+ client.advancements.update(:advancement_id, params)
104
+ client.advancements.destroy(:advancement_id)
105
+ ```
106
+
107
+ - [Advancement Devolutions](http://developers.rexpense.com/api/v1/advancement_devolutions/)
108
+ ```ruby
109
+ client.advancement_devolutions.create
110
+ ```
111
+
112
+ - [Expenses](http://developers.rexpense.com/api/v1/expenses/)
113
+ ```ruby
114
+ client.expenses.find_all
115
+ client.expenses.find(:expense_id)
116
+ client.expenses.create(params)
117
+ client.expenses.update(:expense_id, params)
118
+ client.expenses.destroy(:expense_id)
119
+ ```
120
+
121
+ - [Organizations](http://developers.rexpense.com/api/v1/organizations/)
122
+ ```ruby
123
+ client.organizations.find_all
124
+ client.organizations.find(:organization_id)
125
+ client.organizations.update(:organization_id, params)
126
+ client.organizations.destroy(:organization_id)
127
+ ```
128
+
129
+ - [Memberships](http://developers.rexpense.com/api/v1/memberships/)
130
+ ```ruby
131
+ client.organizations.memberships(:organization_id)
132
+ client.organizations.find_memberships(:organization_id, :membership_id)
133
+ client.organizations.create_memberships(:organization_id, params)
134
+ client.organizations.update_memberships(:organization_id, :membership_id, params)
135
+ client.organizations.destroy_memberships(:organization_id, :membership_id)
136
+ ```
137
+
138
+ - [PreExpenses](http://developers.rexpense.com/api/v1/pre_expenses/)
139
+ ```ruby
140
+ client.pre_expenses.find_all
141
+ client.pre_expenses.find(:pre_expense_id)
142
+ client.pre_expenses.ignore(:pre_expense_id)
143
+ client.pre_expenses.restore(:pre_expense_id)
144
+ client.pre_expenses.convert(:pre_expense_id, params)
145
+ ```
146
+
147
+ - [Tags](http://developers.rexpense.com/api/v1/tags/)
148
+ ```ruby
149
+ client.tags.find_all(:organization_id)
150
+ client.tags.find(:organization_id, :tag_id)
151
+ client.tags.create(:organization_id, params)
152
+ client.tags.update(:organization_id, :tag_id, params)
153
+ client.tags.destroy(:organization_id, :tag_id)
154
+ ```
155
+
156
+ - [Webhooks](http://developers.rexpense.com/api/v1/webhooks/)
157
+ ```ruby
158
+ client.webhooks.find_all(:organization_id)
159
+ client.webhooks.find(:organization_id, :webhook_id)
160
+ client.webhooks.create(:organization_id, params)
161
+ client.webhooks.update(:organization_id, :webhook_id, params)
162
+ client.webhooks.destroy(:organization_id, :webhook_id)
163
+ ```
164
+
165
+ ## Development
166
+
167
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
168
+
169
+ To install this gem onto your local machine, run `bundle exec rake install`.
170
+
171
+ ## Release
172
+
173
+ To release a new version, update the version number in `lib/rexpense/version.rb`, run `bundle install` and commit & push the changes to the repository.
174
+
175
+ If this is your first time publishing a RubyGem in your local device, you will have to download your credentials. To do this, follow the instructions in your [profile page in RubyGems](https://rubygems.org/profile/edit) or just type the following in your command line, replacing `$username` with your RubyGems username.
176
+
177
+ ```bash
178
+ $ curl -u $username https://rubygems.org/api/v1/api_key.yaml > ~/.gem/credentials; chmod 0600 ~/.gem/credentials
179
+ ```
180
+
181
+ Then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org). Make sure you have publishing rights for the gem on RubyGems beforehand, though.
182
+
183
+ After publishing the new version, add a comment to each pull request that was included in this release like this:
184
+
185
+ ```
186
+ :shipit: released on [version x.y.z](https://rubygems.org/gems/rexpense/versions/x.y.z)
187
+ ```
188
+
189
+ ## Contributing
190
+
191
+ Bug reports and pull requests are welcome on GitHub at https://github.com/myfreecomm/rexpense-client-ruby. This project is intended to be a safe and welcoming space for collaboration.
192
+
193
+ ## License
194
+
195
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "rexpense"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/rspec ADDED
@@ -0,0 +1,21 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ load File.expand_path("../spring", __FILE__)
4
+ rescue LoadError => e
5
+ raise unless e.message.include?("spring")
6
+ end
7
+ #
8
+ # This file was generated by Bundler.
9
+ #
10
+ # The application "rspec" is installed as part of a gem, and
11
+ # this file is here to facilitate running it.
12
+ #
13
+
14
+ require "pathname"
15
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
16
+ Pathname.new(__FILE__).realpath)
17
+
18
+ require "rubygems"
19
+ require "bundler/setup"
20
+
21
+ load Gem.bin_path("rspec-core", "rspec")
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,39 @@
1
+ require "rexpense/request"
2
+ require "rexpense/response"
3
+
4
+ module Rexpense
5
+ class Client
6
+ attr_reader :http
7
+
8
+ def initialize(token)
9
+ @http = Http.new(token)
10
+ end
11
+
12
+ def authenticated?
13
+ http.get("/organizations") { |response| response.code == 200 }
14
+ rescue RequestError => e
15
+ raise e unless [401, 403].include?(e.code)
16
+ false
17
+ end
18
+
19
+ # Define available endpoints
20
+
21
+ def activities
22
+ Rexpense::Resources::Activity.new(http)
23
+ end
24
+
25
+ def advancement_devolutions
26
+ Rexpense::Resources::AdvancementDevolution.new(http)
27
+ end
28
+
29
+ def pre_expenses
30
+ Rexpense::Resources::PreExpense.new(http)
31
+ end
32
+
33
+ %w(organization expense advancement reimbursement tag webhook membership comment user).each do |endpoint|
34
+ define_method(endpoint + 's') do
35
+ Object.const_get("Rexpense::Resources::#{endpoint.capitalize}").new(http)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,13 @@
1
+ require "base64"
2
+
3
+ module Rexpense
4
+ class Configuration
5
+ attr_accessor :user_agent, :api_mode, :version
6
+
7
+ def initialize
8
+ @api_mode = 'production'
9
+ @version = 'v1'
10
+ @user_agent = "Rexpense Ruby Client v#{Rexpense::VERSION}"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module Rexpense
2
+ module Entities
3
+ class Activity < Base
4
+ attribute :id, Integer
5
+ attribute :subject, Hash
6
+ attribute :source, Hash
7
+ attribute :user, Rexpense::Entities::Organization
8
+ attribute :changes, String
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,14 @@
1
+ module Rexpense
2
+ module Entities
3
+ #
4
+ # A wrapper to Activity collection
5
+ #
6
+ class ActivityCollection < Collection
7
+ def build_collection
8
+ response.parsed_body['activities'].each do |attributes|
9
+ collection.push(Rexpense::Entities::Activity.new(attributes))
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Rexpense
2
+ module Entities
3
+ class Advancement < Base
4
+ [:id, :comments_count, :activities_count].each { |n| attribute n, Integer }
5
+ [:description, :currency].each { |n| attribute n, String }
6
+ attribute :amount, Decimal
7
+ attribute :tags, Array[String]
8
+ attribute :created_at, DateTime
9
+ attribute :updated_at, DateTime
10
+ attribute :payer, Rexpense::Entities::Organization
11
+ attribute :receiver, Rexpense::Entities::User
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Rexpense
2
+ module Entities
3
+ #
4
+ # A wrapper to Advancement collection
5
+ #
6
+ class AdvancementCollection < Collection
7
+ def build_collection
8
+ response.parsed_body['advancements'].each do |attributes|
9
+ collection.push(Rexpense::Entities::Advancement.new(attributes))
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module Rexpense
2
+ module Entities
3
+ class AdvancementDevolution < Base
4
+ attribute :id, Integer
5
+ attribute :currency, String
6
+ attribute :amount, Decimal
7
+ attribute :deleted_at, DateTime
8
+ attribute :date, DateTime
9
+ attribute :payer, Rexpense::Entities::Organization
10
+ attribute :receiver, Rexpense::Entities::User
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ module Rexpense
2
+ module Entities
3
+ class Attachment < Base
4
+ attribute :id, Integer
5
+ attribute :description, String
6
+ attribute :content_type, String
7
+ attribute :file_name, String
8
+ attribute :url, String
9
+ attribute :user, Rexpense::Entities::User
10
+ attribute :uploaded_at, DateTime
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module Rexpense
2
+ module Entities
3
+ #
4
+ # A wrapper to Attachment collection
5
+ #
6
+ class AttachmentCollection < Collection
7
+ def build_collection
8
+ response.parsed_body['attachments'].each do |attributes|
9
+ collection.push(Rexpense::Entities::Attachment.new(attributes))
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ require "virtus"
2
+
3
+ module Rexpense
4
+ module Entities
5
+ class Base
6
+ include Virtus.model
7
+ end
8
+ end
9
+ end