patient_zero 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/lib/patient_zero/profile.rb +31 -0
- data/lib/patient_zero/version.rb +1 -1
- data/lib/patient_zero.rb +2 -1
- data/spec/patient_zero/profile_spec.rb +64 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b70009e4968e63500d72f6764132b925d4e1b242
|
4
|
+
data.tar.gz: fcfa41d4ae1bccc8993bb99a7eed66d375c681ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c4e93faa37fccf1fa215f12cb72e60bf0418ab8d9c01e497dc6208356747e8476a94fae9203e81adf89f03c95c640dc0fba331c1981595b9f97e56f5ba4ed32
|
7
|
+
data.tar.gz: 21b59f18e6a67fc44d854c646b223ba2e4b56737ad1bcffa01f9ea0f9f379dd68c0f429f8844e53fea1af53f1ebb0ab0d0e1e66e438a6d0ed430aa78ae5cd740
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module PatientZero
|
2
|
+
class Profile < Client
|
3
|
+
CATEGORIES = ['General', 'Brand', 'Television', 'Movies', 'Music', 'Person', 'Sports', 'Politics', 'Topic']
|
4
|
+
|
5
|
+
attr_accessor :id, :expression, :name, :category
|
6
|
+
|
7
|
+
def initialize attributes
|
8
|
+
@id = attributes.fetch 'id'
|
9
|
+
@expression = attributes.fetch 'expression'
|
10
|
+
@name = attributes.fetch 'name'
|
11
|
+
@category = attributes.fetch 'category'
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.all
|
15
|
+
response = get '/social/api/v2/monitoring/profiles', api_key: PatientZero.api_key
|
16
|
+
response['profiles'].map do |profile_attributes|
|
17
|
+
new profile_attributes
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.find id
|
22
|
+
response = get '/social/api/v2/monitoring/profiles', api_key: PatientZero.api_key, id: id
|
23
|
+
new response['profiles'].first
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.create params={}
|
27
|
+
response = post '/social/api/v2/monitoring/profiles', api_key: PatientZero.api_key, profile: params
|
28
|
+
new response['profile']
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/patient_zero/version.rb
CHANGED
data/lib/patient_zero.rb
CHANGED
@@ -9,6 +9,7 @@ require 'patient_zero/organization'
|
|
9
9
|
require 'patient_zero/analytics'
|
10
10
|
require 'patient_zero/source'
|
11
11
|
require 'patient_zero/message'
|
12
|
+
require 'patient_zero/profile'
|
12
13
|
|
13
14
|
module PatientZero
|
14
15
|
extend PatientZero::Configurable
|
@@ -19,4 +20,4 @@ end
|
|
19
20
|
# config.api_key = 'somethingsomethingdangerzone'
|
20
21
|
# config.email = 'duchess@cia.gov'
|
21
22
|
# config.password = 'password'
|
22
|
-
# end
|
23
|
+
# end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
module PatientZero
|
4
|
+
describe Profile do
|
5
|
+
let(:id) { 12345 }
|
6
|
+
let(:token) { 'token-shmoken' }
|
7
|
+
let(:category) { 'blooper' }
|
8
|
+
let(:name) { 'blooper' }
|
9
|
+
let(:expression) { 'blooper' }
|
10
|
+
let(:profiles) { [profile_data] }
|
11
|
+
let(:profile_data) do
|
12
|
+
{
|
13
|
+
"id" => id,
|
14
|
+
"expression"=>name,
|
15
|
+
"name"=>expression,
|
16
|
+
"category"=>category
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
before { allow(Authorization).to receive(:token).and_return token }
|
21
|
+
|
22
|
+
describe '.all' do
|
23
|
+
let(:profile_response) { response_with_body profiles: profiles }
|
24
|
+
before { allow(Client.connection).to receive(:get).with('/social/api/v2/monitoring/profiles', anything) { profile_response } }
|
25
|
+
|
26
|
+
it 'calls the profiles api endpoint' do
|
27
|
+
expect(Client.connection).to receive(:get).with('/social/api/v2/monitoring/profiles', anything)
|
28
|
+
Profile.all
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns an Array of Profile objects' do
|
32
|
+
expect(Profile.all.first).to be_a Profile
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '.find' do
|
37
|
+
let(:profile_response) { response_with_body profiles: [profile_data] }
|
38
|
+
before { allow(Client.connection).to receive(:get).with('/social/api/v2/monitoring/profiles', anything) { profile_response } }
|
39
|
+
|
40
|
+
it 'calls the profiles api endpoint' do
|
41
|
+
expect(Client.connection).to receive(:get).with('/social/api/v2/monitoring/profiles', anything)
|
42
|
+
Profile.find id
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'returns a Profile object' do
|
46
|
+
expect(Profile.find(id)).to be_a Profile
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
describe '.create' do
|
51
|
+
let(:profile_response) { response_with_body profile: profile_data }
|
52
|
+
before { allow(Client.connection).to receive(:post).with('/social/api/v2/monitoring/profiles', anything) { profile_response } }
|
53
|
+
|
54
|
+
it 'calls the profiles api endpoint' do
|
55
|
+
expect(Client.connection).to receive(:post).with('/social/api/v2/monitoring/profiles', anything)
|
56
|
+
Profile.create profile_data
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns a Profile object' do
|
60
|
+
expect(Profile.create(profile_data)).to be_a Profile
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patient_zero
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Zaninovich
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- lib/patient_zero/message/instagram.rb
|
126
126
|
- lib/patient_zero/message/twitter.rb
|
127
127
|
- lib/patient_zero/organization.rb
|
128
|
+
- lib/patient_zero/profile.rb
|
128
129
|
- lib/patient_zero/source.rb
|
129
130
|
- lib/patient_zero/version.rb
|
130
131
|
- patient_zero.gemspec
|
@@ -140,6 +141,7 @@ files:
|
|
140
141
|
- spec/patient_zero/message/twitter_spec.rb
|
141
142
|
- spec/patient_zero/message_spec.rb
|
142
143
|
- spec/patient_zero/organization_spec.rb
|
144
|
+
- spec/patient_zero/profile_spec.rb
|
143
145
|
- spec/patient_zero/source_spec.rb
|
144
146
|
- spec/spec_helper.rb
|
145
147
|
homepage: ''
|
@@ -162,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
164
|
version: '0'
|
163
165
|
requirements: []
|
164
166
|
rubyforge_project:
|
165
|
-
rubygems_version: 2.
|
167
|
+
rubygems_version: 2.2.2
|
166
168
|
signing_key:
|
167
169
|
specification_version: 4
|
168
170
|
summary: A gem to use the Viral Heat API
|
@@ -179,5 +181,7 @@ test_files:
|
|
179
181
|
- spec/patient_zero/message/twitter_spec.rb
|
180
182
|
- spec/patient_zero/message_spec.rb
|
181
183
|
- spec/patient_zero/organization_spec.rb
|
184
|
+
- spec/patient_zero/profile_spec.rb
|
182
185
|
- spec/patient_zero/source_spec.rb
|
183
186
|
- spec/spec_helper.rb
|
187
|
+
has_rdoc:
|