outreach 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 896ed42c45cb4f5764a88236b9fe427e3b1a0aa5
4
- data.tar.gz: a957060f07a0a383da1c757ffff61d4ad11d15b6
3
+ metadata.gz: fe1c9b5714bb38174c441cb266cd46381aa3110d
4
+ data.tar.gz: b818c9939969cb205bcb7e86b76c7e7aa76817cb
5
5
  SHA512:
6
- metadata.gz: 08d825b753f669009e5bd3ffc1952e8bc4bacd894e754f00a2ed7cc41ee874b8646bf72ef2974ca7fa1030b3a12a664c9fdce0c503b92caf1bc822ecaae0fae0
7
- data.tar.gz: ba92fcf9533e4e3689d612692dd4b97d9d5c8f6fd8f030e933f5840d361932ced90f6a1134097440081d5ff4775d1f48a926e2c5790bd6c2ee2866d0143eecee
6
+ metadata.gz: 6e6766d6f9a6095003e293b30605dc68087c61a47014130aae05aba290f5c949c3c54d39ec00df5771c1cae6dc452046a6f1a627439b8037b36c6cd8f8bdf0d7
7
+ data.tar.gz: ffae74024011ff42c117d485811f663c31a75f7e8f05041f18b0353dc5f46c8fb782855bbbb97f7ce8d96f690edf1d26de40565b506223ca59ee5b6caefedae6
data/README.md CHANGED
@@ -39,7 +39,7 @@ First off you need to grab the authorization key for your user. You do this by g
39
39
 
40
40
  For example, if using Rails this could be in a view
41
41
  ```
42
- <%= link_to("Connect to Outreach", Outreach::Authorization.authorization_url)
42
+ <%= link_to("Connect to Outreach", Outreach::Authorization.authorization_url) %>
43
43
  ```
44
44
 
45
45
  This will take the user through the oauth process - afterwards they will be redirected back to your site to whatever the url you have setup in Outreach.redirect_uri. This will also provide the authorization key so you can get access for that user using the Outreach::Authorization.create method.
@@ -77,13 +77,13 @@ user.save
77
77
  ## API Client
78
78
  Once you have the access code for a user you can then create an api client for that user.
79
79
  ```ruby
80
- client = Outreach::Client.new(user.access_code)
80
+ outreach = Outreach::Client.new(user.access_code)
81
81
  ```
82
82
 
83
83
  ## Prospects
84
84
  To find all prospects:
85
85
  ```ruby
86
- client.prospects.all
86
+ outreach.prospects.find_all
87
87
  # returns an array of prospects
88
88
  ```
89
89
 
@@ -94,17 +94,17 @@ Filtering is possible by using the following conditions:
94
94
  # email
95
95
  # company_name
96
96
  # e.g.
97
- client.prospects.all({ first_name: "Chris", last_name: "O'Sullivan" })
97
+ outreach.prospects.find_all({ first_name: "Chris", last_name: "O'Sullivan" })
98
98
  ```
99
99
 
100
- The results of client.prospects.all is paginated. You can control pagination by passing in which page you want to see:
100
+ The results of outreach.prospects.find_all is paginated. You can control pagination by passing in which page you want to see:
101
101
  ```ruby
102
- client.prospects.all({ page: 2 })
102
+ outreach.prospects.find_all({ page: 2 })
103
103
  ```
104
104
 
105
105
  You can find a specific prospect given the prospect id:
106
106
  ```ruby
107
- clients.prospect.find(2345)
107
+ outreach.prospects.find(2345)
108
108
  ```
109
109
 
110
110
  ## Contributing
@@ -4,12 +4,10 @@ module Outreach
4
4
  @api_token = api_token
5
5
  end
6
6
 
7
- def prospect
8
- Outreach::ProspectFinder.new(request)
7
+ def prospects
8
+ Outreach::Service::Prospect.new(self)
9
9
  end
10
10
 
11
- private
12
-
13
11
  def request
14
12
  Request.new(@api_token)
15
13
  end
@@ -1,6 +1,6 @@
1
1
  module Outreach
2
2
  class Prospect
3
- attr_accessor :first_name, :last_name, :company, :contact, :tags
3
+ attr_accessor :first_name, :last_name, :company, :contact, :tags, :id
4
4
 
5
5
  def initialize(attrs)
6
6
  @first_name = attrs['attributes']['personal']['name']['first']
@@ -8,6 +8,7 @@ module Outreach
8
8
  @company = to_ostruct(attrs['attributes']['company'])
9
9
  @contact = to_ostruct(attrs['attributes']['contact'])
10
10
  @tags = attrs['attributes']['metadata']['tags']
11
+ @id = attrs['id']
11
12
  end
12
13
 
13
14
  private
@@ -20,39 +21,5 @@ module Outreach
20
21
  o
21
22
  end
22
23
  end
23
-
24
- class ProspectFinder
25
- API_URL = "https://api.outreach.io/1.0/prospects"
26
-
27
- def initialize(request)
28
- @request = request
29
- end
30
-
31
- def find(id)
32
- response = @request.get("#{API_URL}/#{id}")
33
- Prospect.new(response)
34
- end
35
-
36
- def all(attrs={})
37
- response = @request.get(API_URL, attribute_mapping(attrs))
38
- response['data'].map {|attrs| Prospect.new(attrs)}
39
- end
40
-
41
- private
42
-
43
- def attribute_mapping(attrs)
44
- if attrs[:first_name]
45
- attrs["filter[personal/name/first]"] = attrs.delete(:first_name)
46
- end
47
- if attrs[:last_name]
48
- attrs["filter[personal/name/last]"] = attrs.delete(:last_name)
49
- end
50
- attrs["filter[contact/email]"] = attrs.delete(:email) if attrs[:email]
51
- if attrs[:company_name]
52
- attrs["filter[company/name]"] = attrs.delete(company_name)
53
- end
54
- attrs
55
- end
56
- end
57
24
  end
58
25
 
@@ -0,0 +1,43 @@
1
+ module Outreach
2
+ module Service
3
+ class Prospect
4
+ def initialize(client)
5
+ @request = client.request
6
+ end
7
+
8
+ def find(id)
9
+ response = @request.get("#{api_url}/#{id}")
10
+ collection_class.new(response['data'])
11
+ end
12
+
13
+ def find_all(attrs={})
14
+ response = @request.get(api_url, attribute_mapping(attrs))
15
+ response['data'].map {|attrs| collection_class.new(attrs)}
16
+ end
17
+
18
+ protected
19
+
20
+ def api_url
21
+ "https://api.outreach.io/1.0/prospects"
22
+ end
23
+
24
+ def collection_class
25
+ Outreach::Prospect
26
+ end
27
+
28
+ def attribute_mapping(attrs)
29
+ if attrs[:first_name]
30
+ attrs["filter[personal/name/first]"] = attrs.delete(:first_name)
31
+ end
32
+ if attrs[:last_name]
33
+ attrs["filter[personal/name/last]"] = attrs.delete(:last_name)
34
+ end
35
+ attrs["filter[contact/email]"] = attrs.delete(:email) if attrs[:email]
36
+ if attrs[:company_name]
37
+ attrs["filter[company/name]"] = attrs.delete(company_name)
38
+ end
39
+ attrs
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,3 +1,3 @@
1
1
  module Outreach
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/outreach.rb CHANGED
@@ -4,6 +4,7 @@ require "outreach/request"
4
4
  require "outreach/authorization"
5
5
  require "outreach/client"
6
6
  require "outreach/prospect"
7
+ require "outreach/service/prospect"
7
8
 
8
9
  module Outreach
9
10
  class << self
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outreach
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris O'Sullivan
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-05 00:00:00.000000000 Z
11
+ date: 2016-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -114,6 +114,7 @@ files:
114
114
  - lib/outreach/errors.rb
115
115
  - lib/outreach/prospect.rb
116
116
  - lib/outreach/request.rb
117
+ - lib/outreach/service/prospect.rb
117
118
  - lib/outreach/version.rb
118
119
  - outreach.gemspec
119
120
  homepage: