manifestly-client 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9c2c2bbd1db592e25a2a2f60574fc12a752fb5da4f692ea0094ea37457860ef8
4
+ data.tar.gz: 055a7c6ac784cdf413bf18b60a92d7cbe677b1c6305160f8aef8176323a882ea
5
+ SHA512:
6
+ metadata.gz: 619d5222939cb3df4fcd91bd610f3f42aea73e1eafeef0e06acc7f795b34ca39f0d5a445136d491932b0d18742c7abe42f3e0f80ec09865c1d9fa2b88eccfce2
7
+ data.tar.gz: 1c26add7a5839f3c47e7cf5b56ae212227190d98a6caf00d22bb3985fe4f4669ae33d2d588b52c9e504da2cca9678336ff0dcb7928a362f03ec3a47feb6ebb9d
@@ -0,0 +1,12 @@
1
+ ### Steps to reproduce
2
+ Tell us how to make it happen
3
+
4
+ ### Expected behavior
5
+ Tell us what should happen
6
+
7
+ ### Actual behavior
8
+ Tell us what happens instead
9
+
10
+ ### System configuration
11
+ **Operating System version**:
12
+ **Ruby version**:
@@ -0,0 +1,17 @@
1
+ ### Summary
2
+
3
+ Provide a general description of the code changes in your pull
4
+ request... were there any bugs you had fixed? If so, mention them. If
5
+ these bugs have open GitHub issues, be sure to tag them here as well,
6
+ to keep the conversation linked together.
7
+
8
+ ### Other Information
9
+
10
+ If there's anything else that's important and relevant to your pull
11
+ request, mention that information here. This could include
12
+ benchmarks, or other information.
13
+
14
+ If you are updating any of the CHANGELOG files or are asked to update the
15
+ CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file.
16
+
17
+ Thanks for contributing to firespring/manifestly-ruby!
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ coverage/
2
+ Gemfile.lock
3
+ .*DS_Store
4
+ *.gem
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ -c
2
+ -f d
3
+ --profile
data/.rubocop.yml ADDED
@@ -0,0 +1,33 @@
1
+ # This is the configuration used to check the rubocop source code.
2
+ inherit_from: #{RUBOCOP_HOME}/config/default.yml
3
+
4
+ AllCops:
5
+ TargetRubyVersion: 2.4
6
+
7
+ Exclude:
8
+ - 'vendor/**/*'
9
+ - 'spec/**/*'
10
+
11
+ MethodLength:
12
+ Max: 20
13
+
14
+ LineLength:
15
+ Max: 150
16
+
17
+ LeadingCommentSpace:
18
+ Enabled: false
19
+
20
+ CommentAnnotation:
21
+ Enabled: false
22
+
23
+ Documentation:
24
+ Enabled: false
25
+
26
+ SpaceInsideHashLiteralBraces:
27
+ EnforcedStyle: no_space
28
+
29
+ Style/FrozenStringLiteralComment:
30
+ Enabled: false
31
+
32
+ Style/AccessModifierDeclarations:
33
+ EnforcedStyle: inline
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.4
data/.simplecov ADDED
@@ -0,0 +1,3 @@
1
+ SimpleCov.start do
2
+ add_filter '/spec/'
3
+ end
data/.travis.yml ADDED
@@ -0,0 +1,25 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm: 2.4
4
+ script:
5
+ - bundle exec rspec spec/unit
6
+ - bundle exec rubocop
7
+ deploy:
8
+ - provider: releases
9
+ api_key:
10
+ secure: xg82SFFS5Vd99DV6F+9O81Y1yQL/7VMPlSQOMWLY8ZNFkoUsimdKMqNFVuLx2quy7Ui1CtXS4SEb1bdLo+JmmV5Wlrzwjx37l+WMHz3znng3V3UiLnTKlyeKaXFr1meKaFFltdN/p2dTSPaMamw0sbFk+ZvdT1AelFT0lHIouans/WydTOCiUURZ4qrVAUbaC63dV5vWC+7Qo0F9wkRSrXdpbF82xxJF2bH1ZCLZrmAgFkVjSbGZAJReMcfAbZB6Y59J+dKiXF31ycH8upkkbp7VHyA7b0F1/RZKfEnJ3kOs5N1wPwQF32esCe5WSaziqWKgNUpXbYFcvFliTrYq52PbUiwc1BvJnWFLuIMqZe4Av0McmYcJ561b+hnCm6/cPuCrnuYajyoPArbI6ir5JUEgzRl3nSF+T/sQph7iMX1j4LnotgTFRO3Erm10oRA6Z8AEwMEIzW38WdGgEpBt7EaQZ4ANk2PNBF7UXpVM26SilJc+2YpROcVVpMPR+6WuMUSamuLGTNc5juMemnKGpeNWIkEL1x0weztuENvwJlwyDprRfzVjnHxgQAJEUrTf5alyKkbnPBa0iZoqF/vCDoaG5utvWG7ct91pJfWKbxZt7rYzNRYBGwR8dJbq/H8eXie70J5izzwqz5Nyk2nWPadnVg8onpWGg0OUWo/lffw=
11
+ file_glob: true
12
+ file: manifestly-client-*.gem
13
+ on:
14
+ tags: true
15
+ rvm: 2.4
16
+ repo: firespring/manifestly-ruby
17
+
18
+ - provider: rubygems
19
+ api_key:
20
+ secure: v/HaDZovJL1mK9PFzBLmU2+bxfshARySwYT2rLGZ5s8GMs8jY9hN58jw6EK2pMkv+L7pwI/pGr7e/619i8ASF32TgH3sBy7mpoHdymC7yi51F11AFW1iMdNx4M3M6A8pkrKWpADEmcvooj0eB2Xn9ymIBYE2WtddJ+aS/OXaVuvfChCZmIXQ7GWH1ZBGaZOQVmEaXnJxyriVnGZ4E+CQiFm4rLsxnQeDUMjWsh4/rhwSsOus8U6+PqX99oqYTieofGBCeyXupQ/4gOo5GLc3ii9DKdA+jhSb1M9FyoELdC2XJSLqJaW8rRP063fUF4JBguMWf3eMM/Uc9i6buwjsc8jthgjoCJRJeckxCeO9cBocH4gdxIcu/R/kudsMLxyNVq+z3/AWrvOAzUKtWbVwyJXoh2Wdhwz6QF1yxEqJiYdaabJmlJUCNP89fmEAtSZohALJGmKxSjEbUlgxti0nkoh2zL7zXIrU6Nhv/Qblgrf3hQ8FXMIHBJt40vZHbQ6A5Ts07SfTUrSFazEgYR+aOxWpg+D/jqvkHii/2j1+cotkEw6itKs+coxDoz0hO1CFPvdZGmT5Sh/9YIDUIUaz+UhMtUqgblK1pfLP78Y+OCq2wH9WM9oEbc453kg1yxcy2G9ylGEcbGGXXPq11C7/YNxq5yNXVJOX78rDLNkk2jU=
21
+ gem: manifestly-client
22
+ on:
23
+ tags: true
24
+ rvm: 2.4
25
+ repo: firespring/manifestly-ruby
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [support@firespring.com](mailto:support@firespring.com). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [https://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: https://contributor-covenant.org
46
+ [version]: https://contributor-covenant.org/version/1/4/
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,45 @@
1
+ ## Code of Conduct
2
+
3
+ This project and everyone participating in it is governed by the [Firespring Code of Conduct](CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code. Please report unacceptable behavior to [support@firespring.com](mailto:support@firespring.com).
4
+
5
+ ## How to contribute
6
+
7
+ #### **Did you find a bug?**
8
+
9
+ * **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/firespring/manifestly-ruby/issues).
10
+
11
+ * If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/firespring/manifestly-ruby/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring.
12
+
13
+ #### **Did you write a patch that fixes a bug?**
14
+
15
+ Pull requests are always appreciated.
16
+
17
+ To get started contributing, fork and clone the repo:
18
+
19
+ ```
20
+ git clone git@github.com:your-username/manifestly-ruby.git
21
+ ```
22
+
23
+ Install development Gems:
24
+
25
+ ```
26
+ bundle install
27
+ ```
28
+
29
+ Make your code changes.
30
+
31
+ Make sure that your changes do not break any existing tests:
32
+
33
+ ```
34
+ rspec spec/unit
35
+ ```
36
+
37
+ Pull requests **will not be accepted** for any additional functionality without adding accompanying tests. Moreover, the repository contains a configuration for [Rubocop](https://github.com/bbatsov/rubocop). Pull requests will also not be accepted that do not pass the rubocop style-check. To check this simply run:
38
+
39
+ ```
40
+ rubocop
41
+ ```
42
+
43
+ Open a new GitHub pull request for the patch.
44
+
45
+ Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development, :test do
6
+ gem 'factory_bot'
7
+ gem 'faker'
8
+ gem 'rspec'
9
+ gem 'rubocop'
10
+ gem 'simplecov'
11
+ gem 'webmock'
12
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+
data/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # Manifest.ly Ruby Client
2
+
3
+ A Ruby client that enables quick and easy interactions with the Manifest.ly api.
4
+
5
+ ## Getting Started
6
+
7
+ ### Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'manifestly-client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install manifestly-client
22
+
23
+ ### Basic Usage
24
+
25
+ You may begin using the entity methods after specifying the MANIFESTLY_API_KEY variable in the environment.
26
+ ```ruby
27
+ require 'manifestly'
28
+
29
+ ENV['MANIFESTLY_API_KEY'] = '<secret>'
30
+ puts Manifestly::Entity::Workflow.list.inspect
31
+ ```
32
+
33
+ ### Workflow entity
34
+
35
+ You may create a new workflow by passing a hash of data to the Workflow constructor and invoking the `create` method. Some internal fields (like `id`) will be injected back in to the object after it is created.
36
+ ```ruby
37
+ data = {title: 'Test Workflow'}
38
+ workflow = Manifestly::Entity::Workflow.new(data).create
39
+ workflow.create
40
+ ```
41
+
42
+ If you specify an `external_id` for a local reference, Manifest.ly will use an `upsert` methodology (if the workflow does not exist it will be created - otherwise it will be updated). This effectively means that create/update/save function identically for workflows.
43
+ ```ruby
44
+ data = {title: 'Test Workflow with External Id', external_id: 'abc123'}
45
+ workflow = Manifestly::Entity::Workflow.new(data).create
46
+
47
+ workflow.title = "#{workflow.title} (updated)"
48
+ workflow.create
49
+ ```
50
+
51
+ You may delete a workflow if you specified an external_id when creating it.
52
+ ```ruby
53
+ data = {title: 'Test Workflow Delete', external_id: 'def456'}
54
+ workflow = Manifestly::Entity::Workflow.new(data).create
55
+ workflow.delete
56
+ ```
57
+
58
+ ##### Workflow Steps entity
59
+
60
+ Steps may be passed in when creating a workflow via the steps field.
61
+ ```ruby
62
+ data = {title: 'Test Workflow with steps', external_id: 'ghi789', steps: [{title: 'Step One'}]}
63
+ workflow = Manifestly::Entity::Workflow.new(data)
64
+ workflow.create
65
+ ```
66
+
67
+ ### Checklist Run entity
68
+
69
+ You may start a new checklist run by passing a hash of data to the ChecklistRun constructor and invoking the `create` method. You must include the internal id of an existing workflow as the checklist_id. Subsequent modifications of this checklist run or it's steps is only possible if you are listed as one of the users on the run.
70
+ ```ruby
71
+ my_email_address = 'john.smith@foo.bar'
72
+ my_user = Manifestly::Entity::User.list.find { |it| it.email == my_email_address }
73
+
74
+ title = 'Test Workflow with steps'
75
+ workflows = Manifestly::Entity::Workflow.list
76
+ workflow = workflows.find { |it| it.title == title }
77
+
78
+ data = {title: "Test Run", checklist_id: workflow.id, users: [my_user.id]}
79
+ checklist_run = Manifestly::Entity::ChecklistRun.new(data).create
80
+ ```
81
+
82
+ You may complete a checklist step by calling the corresponding method on the step object. Currently you must either be a participant on the run or assigned to the step in order to complete it.
83
+ ```ruby
84
+ my_email_address = 'john.smith@foo.bar'
85
+ my_user = Manifestly::Entity::User.list.find { |it| it.email == my_email_address }
86
+
87
+ checklist = Manifestly::Entity::ChecklistRun.list(title: 'Test Run', status: :started).first
88
+ step = checklist.steps.first
89
+
90
+ step.assign(my_user.id)
91
+ step.complete
92
+ ```
93
+
94
+ ## Supported Ruby Versions
95
+
96
+ This library is currently supported on Ruby 2.4+.
97
+
98
+ ## Versioning
99
+
100
+ This library follows [Semantic Versioning](http://semver.org/).
101
+
102
+ ## Contributing
103
+
104
+ Contributions to this library are always welcome and highly encouraged.
105
+
106
+ See [Contributing](CONTRIBUTING.md) for more information on how to get started.
107
+
108
+ Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See [Code of Conduct](CODE_OF_CONDUCT.md) for more information.
109
+
110
+ ## License
111
+
112
+ This library is licensed under Apache 2.0. Full license text is
113
+ available in [LICENSE](LICENSE.txt).
114
+
115
+ ## Support
116
+
117
+ Please [report bugs at the project on Github](https://github.com/firespring/manifestly-ruby/issues)
118
+
119
+ See [Contributing](CONTRIBUTING.md) for more information on how to get started.
data/lib/manifestly.rb ADDED
@@ -0,0 +1,23 @@
1
+ LIB_DIR = File.realpath(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(LIB_DIR)
3
+ Dir["#{LIB_DIR}/**/*.rb"].sort.each { |file| require file.sub("#{LIB_DIR}/", '').chomp('.rb') }
4
+
5
+ module Manifestly
6
+ module DayOfTheWeek
7
+ MONDAY = 'Monday'.freeze
8
+ TUESDAY = 'Tuesday'.freeze
9
+ WEDNESDAY = 'Wednesday'.freeze
10
+ THURSDAY = 'Thursday'.freeze
11
+ FRIDAY = 'Friday'.freeze
12
+ SATURDAY = 'Saturday'.freeze
13
+ SUNDAY = 'Sunday'.freeze
14
+ WEEKDAY = [MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY].freeze
15
+ WEEKEND = [SATURDAY, SUNDAY].freeze
16
+ end
17
+
18
+ module Duration
19
+ MINUTES = 'minutes'.freeze
20
+ HOURS = 'hours'.freeze
21
+ DAYS = 'days'.freeze
22
+ end
23
+ end
@@ -0,0 +1,60 @@
1
+ module Manifestly
2
+ module Entity
3
+ class Base
4
+ @attributes = nil
5
+
6
+ def initialize(data = {})
7
+ invalids = data.keys - attributes
8
+ raise "The following invalid #{self.class} keys were found: #{invalids}" unless invalids.empty?
9
+
10
+ self.attributes = data
11
+ end
12
+
13
+ def attributes
14
+ self.class.attributes
15
+ end
16
+
17
+ def self.attributes
18
+ @attributes ||= []
19
+ end
20
+
21
+ def attributes=(attrs)
22
+ attrs.each { |k, v| send(:"#{k}=", v) }
23
+ end
24
+
25
+ def self.attr_accessor(*attrs)
26
+ attrs.each { |attr| attributes << attr }
27
+ super
28
+ end
29
+
30
+ def self.attr_reader(*attrs)
31
+ attrs.each { |attr| attributes << attr }
32
+ super
33
+ end
34
+
35
+ def self.invalid_method(*names)
36
+ names&.each { |name| define_method(name) { |*_, **_| raise 'invalid method' } }
37
+ end
38
+
39
+ def self.invalid_class_method(*names)
40
+ names&.each { |name| define_method(name) { |*_, **_| raise 'invalid method' } }
41
+ end
42
+
43
+ def to_h
44
+ {}.tap do |hsh|
45
+ attributes.each do |attr|
46
+ value = send(attr)
47
+ if value.is_a?(Array)
48
+ value = value.map do |it|
49
+ next it.to_h if it.is_a?(Manifestly::Entity::Base)
50
+
51
+ it
52
+ end
53
+ end
54
+ hsh[attr] = value
55
+ end
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,46 @@
1
+ require_relative 'endpoint'
2
+
3
+ module Manifestly
4
+ module Entity
5
+ class ChecklistRun < Endpoint
6
+ attr_accessor :id
7
+ attr_accessor :account_id
8
+ attr_accessor :archive_url
9
+ attr_accessor :checklist_id
10
+ attr_accessor :checklist_title
11
+ attr_accessor :completed_at
12
+ attr_accessor :description
13
+ attr_accessor :detailed_title
14
+ attr_accessor :external_id
15
+ attr_accessor :late_at
16
+ attr_accessor :percent_completed
17
+ attr_accessor :started_at
18
+ attr_accessor :state
19
+ attr_accessor :summary
20
+ attr_accessor :tag_list
21
+ attr_accessor :title
22
+ attr_accessor :version
23
+ attr_accessor :hide_steps_from_external
24
+ attr_accessor :only_assigned_can_complete
25
+ attr_reader :users
26
+ attr_accessor :origin
27
+
28
+ def self.path
29
+ 'runs'
30
+ end
31
+
32
+ def users=(values)
33
+ @users = Array(values).map do |it|
34
+ next it if it.is_a?(Integer)
35
+ next it[:id] if it.is_a?(Hash) && it[:id]
36
+
37
+ raise "invalid user value #{it}"
38
+ end
39
+ end
40
+
41
+ def steps
42
+ @steps ||= Manifestly::Entity::ChecklistStep.list(self)
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,111 @@
1
+ require_relative 'endpoint'
2
+ require 'date'
3
+
4
+ module Manifestly
5
+ module Entity
6
+ class ChecklistStep < Endpoint
7
+ attr_accessor :id
8
+ attr_accessor :assignee_avatar_url
9
+ attr_accessor :assignee_id
10
+ attr_accessor :assignee_name
11
+ attr_accessor :assignee_user_id
12
+ attr_accessor :assignee_simple_display_name
13
+ attr_accessor :completed_at
14
+ attr_accessor :comments
15
+ attr_accessor :data
16
+ attr_accessor :description_with_links
17
+ attr_accessor :run_detailed_title
18
+ attr_reader :header_step
19
+ attr_accessor :late_at
20
+ attr_accessor :position
21
+ attr_accessor :run_id
22
+ attr_accessor :skipped
23
+ attr_accessor :title
24
+ attr_accessor :user_id
25
+ attr_accessor :user
26
+ attr_accessor :picture
27
+ attr_accessor :run_step_data_setting
28
+
29
+ invalid_method(:create)
30
+ invalid_class_method(:get)
31
+ invalid_method(:update)
32
+ invalid_method(:save)
33
+ invalid_method(:delete)
34
+
35
+ def initialize(run, data = {})
36
+ raise 'invalid checklist run' unless run.is_a?(ChecklistRun)
37
+
38
+ @parent = run
39
+ super(data)
40
+ end
41
+
42
+ # Header step needs to always be a boolean (even if not set)
43
+ def header_step # rubocop:disable DuplicateMethods
44
+ @header_step || false
45
+ end
46
+
47
+ # Always convert to a boolean
48
+ def header_step=(value)
49
+ @header_step = (value.to_s == 'true')
50
+ end
51
+
52
+ def self.path
53
+ 'run_steps'
54
+ end
55
+
56
+ def self.list(run)
57
+ response = client.get("#{run.path}/#{run.id}/#{path}")
58
+ json_entities = JSON.parse(response[:body], symbolize_names: true)[path.to_sym]
59
+ json_entities.map { |it| new(run, it) }
60
+ end
61
+
62
+ def complete
63
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/complete")
64
+ @parent.instance_variable_set(:@steps, nil)
65
+ nil
66
+ end
67
+
68
+ def uncomplete
69
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/uncomplete")
70
+ @parent.instance_variable_set(:@steps, nil)
71
+ nil
72
+ end
73
+
74
+ def skip
75
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/skip")
76
+ @parent.instance_variable_set(:@steps, nil)
77
+ nil
78
+ end
79
+
80
+ def unskip
81
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/unskip")
82
+ @parent.instance_variable_set(:@steps, nil)
83
+ nil
84
+ end
85
+
86
+ def add_data(data)
87
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/data", params: {data: data})
88
+ @parent.instance_variable_set(:@steps, nil)
89
+ nil
90
+ end
91
+
92
+ def add_picture(base_64_encoded_picture_data)
93
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/picture", params: {picture: base_64_encoded_picture_data})
94
+ @parent.instance_variable_set(:@steps, nil)
95
+ nil
96
+ end
97
+
98
+ def add_comment(comment)
99
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/comments", params: {comment: comment})
100
+ @parent.instance_variable_set(:@steps, nil)
101
+ nil
102
+ end
103
+
104
+ def assign(user_id)
105
+ client.post("#{@parent.path}/#{@parent.id}/#{path}/#{id}/assign", params: {assignee_user_id: user_id})
106
+ @parent.instance_variable_set(:@steps, nil)
107
+ nil
108
+ end
109
+ end
110
+ end
111
+ end
@@ -0,0 +1,63 @@
1
+ require_relative 'base'
2
+ require 'json'
3
+
4
+ module Manifestly
5
+ module Entity
6
+ class Endpoint < Base
7
+ @client = nil
8
+
9
+ def path
10
+ self.class.path
11
+ end
12
+
13
+ def self.path
14
+ raise 'Must override method'
15
+ end
16
+
17
+ def client
18
+ self.class.client
19
+ end
20
+
21
+ def self.client
22
+ @client ||= Manifestly::Client.new
23
+ end
24
+
25
+ def create
26
+ response = client.post(path, params: to_h)
27
+ json_entity = JSON.parse(response[:body], symbolize_names: true)[path.chomp('s').to_sym]
28
+ self.attributes = json_entity
29
+ self
30
+ end
31
+
32
+ def self.list(**params)
33
+ response = client.get(path, params: params)
34
+ json_entities = JSON.parse(response[:body], symbolize_names: true)[path.to_sym]
35
+ json_entities.map { |it| new(it) }
36
+ end
37
+
38
+ def self.get(id)
39
+ response = client.get("#{path}/#{id}")
40
+ json_entity = JSON.parse(response[:body], symbolize_names: true)[path.chomp('s').to_sym]
41
+ new(json_entity)
42
+ end
43
+
44
+ def update
45
+ client.post("#{path}/#{id}", params: to_h)
46
+ self
47
+ end
48
+
49
+ def save
50
+ if id
51
+ update
52
+ else
53
+ create
54
+ end
55
+ end
56
+
57
+ def delete
58
+ client.delete(path, params: {external_id: external_id})
59
+ nil
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,26 @@
1
+ require_relative 'endpoint'
2
+
3
+ module Manifestly
4
+ module Entity
5
+ class User < Endpoint
6
+ attr_accessor :id
7
+ attr_accessor :avatar_url
8
+ attr_accessor :email
9
+ attr_accessor :name
10
+ attr_accessor :simple_display_name
11
+ attr_accessor :username
12
+ attr_accessor :membership_id
13
+ attr_accessor :role
14
+
15
+ invalid_method(:create)
16
+ invalid_class_method(:get)
17
+ invalid_method(:update)
18
+ invalid_method(:save)
19
+ invalid_method(:delete)
20
+
21
+ def self.path
22
+ 'users'
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,45 @@
1
+ require_relative 'endpoint'
2
+
3
+ module Manifestly
4
+ module Entity
5
+ class Workflow < Endpoint
6
+ attr_accessor :id
7
+ attr_accessor :account_id
8
+ attr_accessor :business_days
9
+ attr_accessor :description
10
+ attr_accessor :expected_duration
11
+ attr_accessor :expected_duration_units
12
+ attr_accessor :external_id
13
+ attr_accessor :hide_steps_from_external
14
+ attr_reader :steps
15
+ attr_reader :tag_list
16
+ attr_accessor :title
17
+
18
+ def self.path
19
+ 'checklists'
20
+ end
21
+
22
+ # Workflows use an 'upsert' methodology so the create and update routes are shared.
23
+ # Lookups are done via the external_id you pass in
24
+ def update
25
+ create
26
+ end
27
+
28
+ def steps # rubocop:disable DuplicateMethods
29
+ return @steps if @steps
30
+
31
+ # If you are trying to get the steps on a workflow returned by the `list` functionality,
32
+ @steps = self.class.get(id).steps if id
33
+ @steps ||= []
34
+ end
35
+
36
+ def steps=(values)
37
+ @steps = Array(values).map { |it| WorkflowStep.new(self, it) }
38
+ end
39
+
40
+ def tag_list=(values)
41
+ @tag_list = Array(values).map(&:upcase)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,40 @@
1
+ require_relative 'endpoint'
2
+
3
+ module Manifestly
4
+ module Entity
5
+ class WorkflowStep < Base
6
+ attr_accessor :id
7
+ attr_accessor :checklist_id
8
+ attr_accessor :position
9
+ attr_accessor :title
10
+ attr_accessor :description
11
+ attr_accessor :description_with_links
12
+ attr_accessor :created_at
13
+ attr_accessor :updated_at
14
+ attr_reader :header_step
15
+ attr_accessor :active
16
+ attr_accessor :original_id
17
+ attr_accessor :late_at_offset
18
+ attr_accessor :late_at_offset_units
19
+ attr_accessor :late_at_basis
20
+ attr_accessor :parent_step_id
21
+
22
+ def initialize(workflow, data = {})
23
+ raise 'invalid workflow' unless workflow.is_a?(Workflow)
24
+
25
+ @parent = workflow
26
+ super(data)
27
+ end
28
+
29
+ # Header step needs to always be a boolean (even if not set)
30
+ def header_step # rubocop:disable DuplicateMethods
31
+ @header_step || false
32
+ end
33
+
34
+ # Always convert to a boolean
35
+ def header_step=(value)
36
+ @header_step = (value.to_s == 'true')
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,75 @@
1
+ require 'faraday'
2
+
3
+ module Manifestly
4
+ class Client
5
+ DEFAULT_URL = 'https://manifest.ly/api'.freeze
6
+ DEFAULT_API_VERSION = 'v1'.freeze
7
+
8
+ attr_reader :url, :api_version, :api_key
9
+
10
+ def initialize(url: ENV['MANIFESTLY_URL'], api_version: ENV['MANIFESTLY_API_VERSION'], api_key: ENV['MANIFESTLY_API_KEY'])
11
+ @url = url || DEFAULT_URL
12
+ @api_version = api_version || DEFAULT_API_VERSION
13
+ @api_key = api_key || raise('api key is required')
14
+ end
15
+
16
+ def get(path, params: {}, headers: {})
17
+ handle_request { raw_get("#{url}/#{api_version}/#{path}", params: params, headers: headers) }
18
+ end
19
+
20
+ private def raw_get(path, params: {}, headers: {})
21
+ include_api_key!(params)
22
+ include_json_accept!(headers)
23
+ Faraday.get(path, params, headers)
24
+ end
25
+
26
+ def post(path, params: {}, headers: {})
27
+ handle_request { raw_post("#{url}/#{api_version}/#{path}", params: params, headers: headers) }
28
+ end
29
+
30
+ private def raw_post(path, params: {}, headers: {})
31
+ include_api_key!(params)
32
+ include_json_content_type!(headers)
33
+ include_json_accept!(headers)
34
+ Faraday.post(path, params.to_json, headers)
35
+ end
36
+
37
+ def delete(path, params: {}, headers: {})
38
+ handle_request { raw_delete("#{url}/#{api_version}/#{path}", params: params, headers: headers) }
39
+ end
40
+
41
+ private def raw_delete(path, params: {}, headers: {})
42
+ include_api_key!(params)
43
+ include_json_accept!(headers)
44
+ Faraday.delete(path, params, headers)
45
+ end
46
+
47
+ private def include_api_key!(params)
48
+ params.merge!(api_key: api_key)
49
+ end
50
+
51
+ private def include_json_content_type!(headers)
52
+ headers.merge!('Content-Type': 'application/json')
53
+ end
54
+
55
+ private def include_json_accept!(headers)
56
+ headers.merge!('Accept': 'application/json')
57
+ end
58
+
59
+ private def handle_request
60
+ short_response = trim_response(yield)
61
+ case short_response[:status]
62
+ when 404
63
+ raise Faraday::Error::ResourceNotFound, short_response
64
+ when 400...600
65
+ raise Faraday::Error::ClientError, short_response
66
+ end
67
+
68
+ short_response
69
+ end
70
+
71
+ private def trim_response(full_response)
72
+ {status: full_response.status, headers: full_response.headers, body: full_response.body}
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,3 @@
1
+ module Manifestly
2
+ VERSION = '0.0.0'.freeze
3
+ end
@@ -0,0 +1,22 @@
1
+ $LOAD_PATH.unshift("#{__dir__}/lib")
2
+ require 'manifestly/version'
3
+
4
+ Gem::Specification.new do |spec|
5
+ spec.name = 'manifestly-client'
6
+ spec.version = Manifestly::VERSION
7
+ spec.licenses = ['Apache-2.0']
8
+ spec.authors = ['Firespring']
9
+ spec.email = ['info.dev@firespring.com']
10
+
11
+ spec.homepage = 'https://github.com/firespring/manifestly-ruby'
12
+ spec.summary = 'Manifest.ly client library for ruby'
13
+ spec.description = 'A Ruby client that enables quick and easy interactions with the Manifest.ly api'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'faraday', '~> 0.15'
21
+ spec.add_development_dependency 'bundler', '~> 1.7'
22
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: manifestly-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Firespring
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-11-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.15'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ description: A Ruby client that enables quick and easy interactions with the Manifest.ly
42
+ api
43
+ email:
44
+ - info.dev@firespring.com
45
+ executables: []
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".github/ISSUE_TEMPLATE.md"
50
+ - ".github/PULL_REQUEST_TEMPLATE.md"
51
+ - ".gitignore"
52
+ - ".rspec"
53
+ - ".rubocop.yml"
54
+ - ".ruby-version"
55
+ - ".simplecov"
56
+ - ".travis.yml"
57
+ - CODE_OF_CONDUCT.md
58
+ - CONTRIBUTING.md
59
+ - Gemfile
60
+ - LICENSE.txt
61
+ - README.md
62
+ - lib/manifestly.rb
63
+ - lib/manifestly/entity/base.rb
64
+ - lib/manifestly/entity/checklist_run.rb
65
+ - lib/manifestly/entity/checklist_step.rb
66
+ - lib/manifestly/entity/endpoint.rb
67
+ - lib/manifestly/entity/user.rb
68
+ - lib/manifestly/entity/workflow.rb
69
+ - lib/manifestly/entity/workflow_step.rb
70
+ - lib/manifestly/http/client.rb
71
+ - lib/manifestly/version.rb
72
+ - manifestly-client.gemspec
73
+ homepage: https://github.com/firespring/manifestly-ruby
74
+ licenses:
75
+ - Apache-2.0
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.7.7
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Manifest.ly client library for ruby
97
+ test_files: []