prosperworks-ruby 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +109 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/prosperworks.rb +47 -0
- data/lib/prosperworks/api_operations/connect.rb +71 -0
- data/lib/prosperworks/api_operations/create.rb +20 -0
- data/lib/prosperworks/api_operations/delete.rb +28 -0
- data/lib/prosperworks/api_operations/find.rb +18 -0
- data/lib/prosperworks/api_operations/list.rb +30 -0
- data/lib/prosperworks/api_operations/update.rb +21 -0
- data/lib/prosperworks/base.rb +25 -0
- data/lib/prosperworks/base_entity.rb +20 -0
- data/lib/prosperworks/client.rb +29 -0
- data/lib/prosperworks/company.rb +20 -0
- data/lib/prosperworks/configuration.rb +19 -0
- data/lib/prosperworks/errors/bad_request.rb +15 -0
- data/lib/prosperworks/errors/base.rb +15 -0
- data/lib/prosperworks/errors/forbidden.rb +15 -0
- data/lib/prosperworks/errors/not_found.rb +15 -0
- data/lib/prosperworks/errors/rate_limit.rb +14 -0
- data/lib/prosperworks/errors/server_error.rb +15 -0
- data/lib/prosperworks/errors/unauthorized.rb +15 -0
- data/lib/prosperworks/errors/unprocessable.rb +15 -0
- data/lib/prosperworks/lead.rb +30 -0
- data/lib/prosperworks/opportunity.rb +23 -0
- data/lib/prosperworks/person.rb +28 -0
- data/lib/prosperworks/project.rb +12 -0
- data/lib/prosperworks/task.rb +16 -0
- data/lib/prosperworks/utils.rb +24 -0
- data/lib/prosperworks/version.rb +3 -0
- data/lib/prosperworks/webhook.rb +19 -0
- data/prosperworks-ruby.gemspec +28 -0
- data/sample.rb +5 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 83799d280ed1a8852e37f6c479908691b2824d19
|
4
|
+
data.tar.gz: 39ae89fd82e3324e4708f9ff45083d4dfac841bf
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3005d1c1304ef277b933d4f5ea1017cce880d4192d4d2f0a3f3fb7dcca6a543e40d1cdad044d5744c6df3c11fede9034cc013fb46e5cc64a8a77f9617bb6312c
|
7
|
+
data.tar.gz: 111089593cbb962f1d2a4b33bcf07c15d8fb3f162423e61aae125a06267c8a12978192ae7fd8e1a02c02607dfbc8cbeb228b6270c526823df6a1c0f1f44f3d2c
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at nchandra324@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Neeraj Chandra
|
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,109 @@
|
|
1
|
+
# Prosperworks::Ruby
|
2
|
+
|
3
|
+
A lightweight wrapper for interacting with the [ProsperWorks Developer API](https://www.prosperworks.com/developer_api).
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'prosperworks-ruby'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install prosperworks-ruby
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
This gem offers find, search, post and delete operations for the 6 main entity types: People, Companies, Leads, Tasks, Opportunities & Projects. Additionally, it supports the basic create, find, and delete operations for webhooks.
|
25
|
+
|
26
|
+
To use the proper credentials, the following must be run before using the gem:
|
27
|
+
|
28
|
+
```
|
29
|
+
ProsperWorks.configure do |config|
|
30
|
+
config.user_email = <your_user_email>
|
31
|
+
config.access_token = <your_api_token>
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
35
|
+
To interact with the ProsperWorks API, simply call the relevant entity type and operation:
|
36
|
+
```
|
37
|
+
person = ProsperWorks::Person.find(id)
|
38
|
+
|
39
|
+
person = ProsperWorks::Person.create(attributes)
|
40
|
+
|
41
|
+
#
|
42
|
+
# For update, either update the object in advance, or pass
|
43
|
+
# in a hash of attributes to update
|
44
|
+
#
|
45
|
+
person.name = "some new name"
|
46
|
+
response = ProsperWorks::Person.update(person)
|
47
|
+
# --- OR ---
|
48
|
+
response = ProsperWorks::Person.update(person, attributes)
|
49
|
+
|
50
|
+
response = ProsperWorks::Person.delete(person.id)
|
51
|
+
|
52
|
+
```
|
53
|
+
|
54
|
+
The following entity types are currently supported:
|
55
|
+
* Person
|
56
|
+
* Lead
|
57
|
+
* Companuy
|
58
|
+
* Opportunity
|
59
|
+
* Task
|
60
|
+
* Project
|
61
|
+
* Webhook
|
62
|
+
|
63
|
+
The following operations are currently supported:
|
64
|
+
* Create
|
65
|
+
* Find
|
66
|
+
* Update
|
67
|
+
* Delete
|
68
|
+
* List (only for webhooks)
|
69
|
+
|
70
|
+
```
|
71
|
+
webhooks = ProsperWorks::Webhook.list
|
72
|
+
```
|
73
|
+
|
74
|
+
The response will either be an instance of `ProsperWorks::Errors`, or the entity itself. See the `handle_response` function in [connect.rb](lib/prosperworks/api_operations/connect.rb).
|
75
|
+
|
76
|
+
## Development
|
77
|
+
|
78
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
79
|
+
|
80
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and 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).
|
81
|
+
|
82
|
+
## Contributing
|
83
|
+
|
84
|
+
This gem is fairly new, and can benefit from contributions!
|
85
|
+
|
86
|
+
You can take a look at the [issues](https://github.com/soccernee/prosperworks-ruby/issues) and start by contributing there.
|
87
|
+
|
88
|
+
Wishlist
|
89
|
+
[] continuous integration setup
|
90
|
+
[] add [Rubocop](https://github.com/bbatsov/rubocop)
|
91
|
+
[] code cleanup & refactoring
|
92
|
+
[] improved testing
|
93
|
+
[] search endpoint
|
94
|
+
[] Users API
|
95
|
+
[] Activities API
|
96
|
+
[] Related Items API
|
97
|
+
[] Secondary Resources APIs
|
98
|
+
[] Support for Nested Resources
|
99
|
+
|
100
|
+
|
101
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/soccernee/prosperworks-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
102
|
+
|
103
|
+
## License
|
104
|
+
|
105
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
106
|
+
|
107
|
+
## Code of Conduct
|
108
|
+
|
109
|
+
Everyone interacting in the Prosperworks::Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/soccernee/prosperworks-ruby/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "prosperworks/ruby"
|
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(__FILE__)
|
data/bin/setup
ADDED
data/lib/prosperworks.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'prosperworks/api_operations/connect'
|
2
|
+
require 'prosperworks/utils'
|
3
|
+
|
4
|
+
require 'prosperworks/api_operations/create'
|
5
|
+
require 'prosperworks/api_operations/delete'
|
6
|
+
require 'prosperworks/api_operations/find'
|
7
|
+
require 'prosperworks/api_operations/list'
|
8
|
+
require 'prosperworks/api_operations/update'
|
9
|
+
|
10
|
+
require 'prosperworks/errors/base'
|
11
|
+
require 'prosperworks/errors/bad_request'
|
12
|
+
require 'prosperworks/errors/forbidden'
|
13
|
+
require 'prosperworks/errors/not_found'
|
14
|
+
require 'prosperworks/errors/rate_limit'
|
15
|
+
require 'prosperworks/errors/server_error'
|
16
|
+
require 'prosperworks/errors/unauthorized'
|
17
|
+
require 'prosperworks/errors/unprocessable'
|
18
|
+
|
19
|
+
|
20
|
+
require 'prosperworks/base'
|
21
|
+
require 'prosperworks/base_entity'
|
22
|
+
require 'prosperworks/client'
|
23
|
+
require 'prosperworks/company'
|
24
|
+
require 'prosperworks/configuration'
|
25
|
+
require 'prosperworks/lead'
|
26
|
+
require 'prosperworks/opportunity'
|
27
|
+
require 'prosperworks/person'
|
28
|
+
require 'prosperworks/project'
|
29
|
+
require 'prosperworks/task'
|
30
|
+
require 'prosperworks/version'
|
31
|
+
require 'prosperworks/webhook'
|
32
|
+
|
33
|
+
module ProsperWorks
|
34
|
+
|
35
|
+
def self.reset!
|
36
|
+
@client = nil
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.client
|
40
|
+
@client ||= Client.new
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.configure(&block)
|
44
|
+
reset!
|
45
|
+
client.configure(&block)
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
module ProsperWorks
|
5
|
+
module ApiOperations
|
6
|
+
module Connect
|
7
|
+
|
8
|
+
def get_uri(api_name, id = nil)
|
9
|
+
url = client.base_url + "#{api_name}"
|
10
|
+
url = url + "/#{id}" unless id.nil?
|
11
|
+
URI.parse(url)
|
12
|
+
end
|
13
|
+
|
14
|
+
def send_request(http_type, uri, entity = nil)
|
15
|
+
response = nil
|
16
|
+
headers = client.headers
|
17
|
+
|
18
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
+
http.use_ssl = true
|
20
|
+
http.start do
|
21
|
+
case http_type
|
22
|
+
when "get"
|
23
|
+
request = Net::HTTP::Get.new(uri.request_uri, headers)
|
24
|
+
when "post"
|
25
|
+
request = Net::HTTP::Post.new(uri.request_uri, headers)
|
26
|
+
request.body = entity.to_json
|
27
|
+
when "put"
|
28
|
+
request = Net::HTTP::Put.new(uri.request_uri, headers)
|
29
|
+
request.body = entity.to_json
|
30
|
+
when "delete"
|
31
|
+
request = Net::HTTP::Delete.new(uri.request_uri, headers)
|
32
|
+
end
|
33
|
+
response = http.request(request)
|
34
|
+
end
|
35
|
+
|
36
|
+
response
|
37
|
+
end
|
38
|
+
|
39
|
+
def handle_response(entity, response)
|
40
|
+
case response.code.to_i
|
41
|
+
when 200
|
42
|
+
json_object = JSON.parse(response.body)
|
43
|
+
return json_object if json_object.is_a?(Array)
|
44
|
+
|
45
|
+
|
46
|
+
json_object.each_pair do |key, value|
|
47
|
+
if entity.respond_to?(key.to_sym)
|
48
|
+
entity.send("#{key}=", value)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
entity
|
52
|
+
when Errors::BadRequest.status_code
|
53
|
+
Errors::BadRequest
|
54
|
+
when Errors::Unauthorized.status_code
|
55
|
+
Errors::Unauthorized
|
56
|
+
when Errors::Forbidden.status_code
|
57
|
+
Errors::Forbidden
|
58
|
+
when Errors::NotFound.status_code
|
59
|
+
Errors::NotFound
|
60
|
+
when Errors::Unprocessable.status_code
|
61
|
+
Errors::Unprocessable
|
62
|
+
when Errors::RateLimit.status_code
|
63
|
+
Errors::RateLimit
|
64
|
+
else
|
65
|
+
Errors::ServerError
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module ProsperWorks
|
5
|
+
module ApiOperations
|
6
|
+
module Create
|
7
|
+
|
8
|
+
include ApiOperations::Connect
|
9
|
+
|
10
|
+
def create(attributes)
|
11
|
+
entity = self.new(attributes)
|
12
|
+
uri = get_uri(api_name)
|
13
|
+
|
14
|
+
response = send_request("post", uri, entity)
|
15
|
+
handle_response(self.new, response)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ProsperWorks
|
4
|
+
module ApiOperations
|
5
|
+
module Delete
|
6
|
+
|
7
|
+
include ApiOperations::Connect
|
8
|
+
|
9
|
+
def delete(id)
|
10
|
+
uri = get_uri(api_name, id)
|
11
|
+
|
12
|
+
response = send_request("delete", uri)
|
13
|
+
handle_delete_response(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def handle_delete_response(response)
|
17
|
+
result = handle_response(nil, response)
|
18
|
+
if result.is_a?(ProsperWorks::Errors)
|
19
|
+
# pass the error along
|
20
|
+
result
|
21
|
+
else
|
22
|
+
JSON.parse(response.body)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ProsperWorks
|
4
|
+
module ApiOperations
|
5
|
+
module Find
|
6
|
+
|
7
|
+
include ApiOperations::Connect
|
8
|
+
|
9
|
+
def find(id)
|
10
|
+
uri = get_uri(api_name, id)
|
11
|
+
|
12
|
+
response = send_request("get", uri)
|
13
|
+
handle_response(self.new, response)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ProsperWorks
|
4
|
+
module ApiOperations
|
5
|
+
module List
|
6
|
+
|
7
|
+
include ApiOperations::Connect
|
8
|
+
|
9
|
+
def list
|
10
|
+
uri = get_uri(api_name)
|
11
|
+
|
12
|
+
response = send_request("get", uri)
|
13
|
+
handle_multiple_response(response)
|
14
|
+
end
|
15
|
+
|
16
|
+
def handle_multiple_response(response)
|
17
|
+
result = handle_response(nil, response)
|
18
|
+
if result.is_a?(ProsperWorks::Errors)
|
19
|
+
# pass the error along
|
20
|
+
result
|
21
|
+
else
|
22
|
+
result.map do |webhook|
|
23
|
+
self.new(webhook)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
|
3
|
+
module ProsperWorks
|
4
|
+
module ApiOperations
|
5
|
+
module Update
|
6
|
+
|
7
|
+
include ApiOperations::Connect
|
8
|
+
|
9
|
+
def update(entity ,attributes = {})
|
10
|
+
entity.set_attributes(attributes)
|
11
|
+
id = entity.id
|
12
|
+
|
13
|
+
uri = get_uri(api_name, id)
|
14
|
+
|
15
|
+
response = send_request("put", uri, entity)
|
16
|
+
handle_response(self.new, response)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Base
|
3
|
+
include ProsperWorks::JSONable
|
4
|
+
|
5
|
+
attr_accessor :id,
|
6
|
+
:date_created
|
7
|
+
|
8
|
+
def self.client
|
9
|
+
ProsperWorks.client
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(attributes = {})
|
13
|
+
set_attributes(attributes)
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_attributes(attributes)
|
17
|
+
attributes.each do |key, value|
|
18
|
+
if self.respond_to?(key.to_sym)
|
19
|
+
self.send("#{key}=", value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class BaseEntity < Base
|
3
|
+
|
4
|
+
# used for the 6 main entity types
|
5
|
+
|
6
|
+
attr_accessor :assignee_id,
|
7
|
+
:custom_fields,
|
8
|
+
:date_modified,
|
9
|
+
:details,
|
10
|
+
:name,
|
11
|
+
:tags
|
12
|
+
|
13
|
+
|
14
|
+
extend ApiOperations::Create
|
15
|
+
extend ApiOperations::Delete
|
16
|
+
extend ApiOperations::Find
|
17
|
+
extend ApiOperations::Update
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Client
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
API_VERSION_NUMBER = 1
|
6
|
+
|
7
|
+
def headers
|
8
|
+
{
|
9
|
+
"Content-Type": "application/json",
|
10
|
+
"X-PW-Application": "developer_api",
|
11
|
+
"X-PW-UserEmail": configuration.user_email,
|
12
|
+
"X-PW-AccessToken": configuration.access_token
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
def base_url
|
17
|
+
"https://api.prosperworks.com/developer_api/v#{API_VERSION_NUMBER}/"
|
18
|
+
end
|
19
|
+
|
20
|
+
def configure
|
21
|
+
yield configuration if block_given?
|
22
|
+
end
|
23
|
+
|
24
|
+
def configuration
|
25
|
+
@configuration ||= Configuration.new
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Company < BaseEntity
|
3
|
+
|
4
|
+
attr_accessor :address,
|
5
|
+
:contact_type_id,
|
6
|
+
:date_last_contacted,
|
7
|
+
:email_domain,
|
8
|
+
:interaction_count,
|
9
|
+
:title,
|
10
|
+
|
11
|
+
:phone_numbers,
|
12
|
+
:socials,
|
13
|
+
:websites,
|
14
|
+
|
15
|
+
def self.api_name
|
16
|
+
"companies"
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Configuration
|
3
|
+
CONFIGURABLE_ATTRIBUTES = [
|
4
|
+
:user_email,
|
5
|
+
:access_token
|
6
|
+
]
|
7
|
+
|
8
|
+
attr_accessor *CONFIGURABLE_ATTRIBUTES
|
9
|
+
|
10
|
+
def initialize(attrs = {})
|
11
|
+
self.attributes = attrs
|
12
|
+
end
|
13
|
+
|
14
|
+
def attributes=(attrs = {})
|
15
|
+
attrs.each { |key, value| instance_variable_set("@#{key}", value) }
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Lead < BaseEntity
|
3
|
+
|
4
|
+
attr_accessor :address,
|
5
|
+
:company_name,
|
6
|
+
:customer_source_id,
|
7
|
+
:date_last_contacted,
|
8
|
+
:interaction_count,
|
9
|
+
:monetary_value,
|
10
|
+
:status,
|
11
|
+
:status_id,
|
12
|
+
:title,
|
13
|
+
|
14
|
+
:email,
|
15
|
+
:phone_numbers,
|
16
|
+
:socials,
|
17
|
+
:websites,
|
18
|
+
|
19
|
+
:prefix,
|
20
|
+
:first_name,
|
21
|
+
:middle_name,
|
22
|
+
:last_name,
|
23
|
+
:suffix
|
24
|
+
|
25
|
+
def self.api_name
|
26
|
+
"leads"
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Opportunity < BaseEntity
|
3
|
+
|
4
|
+
attr_accessor :close_date,
|
5
|
+
:company_id,
|
6
|
+
:company_name,
|
7
|
+
:customer_source_id,
|
8
|
+
:interaction_count,
|
9
|
+
:loss_reason_id,
|
10
|
+
:monetary_value,
|
11
|
+
:pipeline_id,
|
12
|
+
:primary_contact_id,
|
13
|
+
:priority,
|
14
|
+
:pipeline_stage_id,
|
15
|
+
:status,
|
16
|
+
:win_probability
|
17
|
+
|
18
|
+
def self.api_name
|
19
|
+
"opportunities"
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Person < BaseEntity
|
3
|
+
|
4
|
+
attr_accessor :address,
|
5
|
+
:company_id,
|
6
|
+
:company_name,
|
7
|
+
:contact_type_id,
|
8
|
+
:date_last_contacted,
|
9
|
+
:interaction_count,
|
10
|
+
:title,
|
11
|
+
|
12
|
+
:emails,
|
13
|
+
:phone_numbers,
|
14
|
+
:socials,
|
15
|
+
:websites,
|
16
|
+
|
17
|
+
:prefix,
|
18
|
+
:first_name,
|
19
|
+
:middle_name,
|
20
|
+
:last_name,
|
21
|
+
:suffix
|
22
|
+
|
23
|
+
def self.api_name
|
24
|
+
"people"
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'json/add/core' # enables serializing of Time and other things
|
3
|
+
|
4
|
+
module ProsperWorks
|
5
|
+
|
6
|
+
#
|
7
|
+
# Modified version of the Jsonable gem, all credit goes to the
|
8
|
+
# authors of that gem
|
9
|
+
#
|
10
|
+
module JSONable
|
11
|
+
|
12
|
+
def to_json(*a)
|
13
|
+
result = {}
|
14
|
+
result['json_class'] = self.class.name
|
15
|
+
self.instance_variables.each do |var|
|
16
|
+
trimmed_var = var.to_s.gsub!("@", "")
|
17
|
+
result[trimmed_var] = self.instance_variable_get var
|
18
|
+
end
|
19
|
+
result.to_json(*a)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ProsperWorks
|
2
|
+
class Webhook < Base
|
3
|
+
|
4
|
+
attr_accessor :event,
|
5
|
+
:secret,
|
6
|
+
:target,
|
7
|
+
:type
|
8
|
+
|
9
|
+
extend ApiOperations::Create
|
10
|
+
extend ApiOperations::Find
|
11
|
+
extend ApiOperations::List
|
12
|
+
extend ApiOperations::Delete
|
13
|
+
|
14
|
+
def self.api_name
|
15
|
+
"webhooks"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "prosperworks/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "prosperworks-ruby"
|
8
|
+
spec.version = ProsperWorks::VERSION
|
9
|
+
spec.authors = ["Neeraj Chandra"]
|
10
|
+
spec.email = ["nchandra324@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{A lightweight interface for the ProsperWorks Developer API}
|
13
|
+
spec.description = %q{A lightweight interface for the ProsperWorks Developer API}
|
14
|
+
spec.homepage = "https://rubygems.org/gems/prosperworks-ruby"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
27
|
+
spec.add_development_dependency "webmock", "~> 3.0"
|
28
|
+
end
|
data/sample.rb
ADDED
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: prosperworks-ruby
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Neeraj Chandra
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-07-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.0'
|
69
|
+
description: A lightweight interface for the ProsperWorks Developer API
|
70
|
+
email:
|
71
|
+
- nchandra324@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- CODE_OF_CONDUCT.md
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/prosperworks.rb
|
86
|
+
- lib/prosperworks/api_operations/connect.rb
|
87
|
+
- lib/prosperworks/api_operations/create.rb
|
88
|
+
- lib/prosperworks/api_operations/delete.rb
|
89
|
+
- lib/prosperworks/api_operations/find.rb
|
90
|
+
- lib/prosperworks/api_operations/list.rb
|
91
|
+
- lib/prosperworks/api_operations/update.rb
|
92
|
+
- lib/prosperworks/base.rb
|
93
|
+
- lib/prosperworks/base_entity.rb
|
94
|
+
- lib/prosperworks/client.rb
|
95
|
+
- lib/prosperworks/company.rb
|
96
|
+
- lib/prosperworks/configuration.rb
|
97
|
+
- lib/prosperworks/errors/bad_request.rb
|
98
|
+
- lib/prosperworks/errors/base.rb
|
99
|
+
- lib/prosperworks/errors/forbidden.rb
|
100
|
+
- lib/prosperworks/errors/not_found.rb
|
101
|
+
- lib/prosperworks/errors/rate_limit.rb
|
102
|
+
- lib/prosperworks/errors/server_error.rb
|
103
|
+
- lib/prosperworks/errors/unauthorized.rb
|
104
|
+
- lib/prosperworks/errors/unprocessable.rb
|
105
|
+
- lib/prosperworks/lead.rb
|
106
|
+
- lib/prosperworks/opportunity.rb
|
107
|
+
- lib/prosperworks/person.rb
|
108
|
+
- lib/prosperworks/project.rb
|
109
|
+
- lib/prosperworks/task.rb
|
110
|
+
- lib/prosperworks/utils.rb
|
111
|
+
- lib/prosperworks/version.rb
|
112
|
+
- lib/prosperworks/webhook.rb
|
113
|
+
- prosperworks-ruby.gemspec
|
114
|
+
- sample.rb
|
115
|
+
homepage: https://rubygems.org/gems/prosperworks-ruby
|
116
|
+
licenses:
|
117
|
+
- MIT
|
118
|
+
metadata: {}
|
119
|
+
post_install_message:
|
120
|
+
rdoc_options: []
|
121
|
+
require_paths:
|
122
|
+
- lib
|
123
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
requirements:
|
130
|
+
- - ">="
|
131
|
+
- !ruby/object:Gem::Version
|
132
|
+
version: '0'
|
133
|
+
requirements: []
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 2.6.12
|
136
|
+
signing_key:
|
137
|
+
specification_version: 4
|
138
|
+
summary: A lightweight interface for the ProsperWorks Developer API
|
139
|
+
test_files: []
|