patient_zero 0.5.7 → 0.5.8

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: 2aa24126e715d27d3a0529f9813dece06db5e590
4
- data.tar.gz: 9ddf973aa5680b4c2eb9f224b746866deced8bb0
3
+ metadata.gz: 153ec2b306afb2cb3246ae44af572dfaf4b3a339
4
+ data.tar.gz: 37465e5232e2e0e79ad005134f381eb50ab56110
5
5
  SHA512:
6
- metadata.gz: a253bcb54cdf7a7999c0c9f9fa54413b369508b8c287230f5304d8514add028eff0a363510bc1e90eee9f815d6e6dc9d7ee1d1e8f585268cd3d87f01bf28f9e1
7
- data.tar.gz: 8b3ce8a4ef8408f3a9c18542d471b107ed9ed1bc59efd417c1a300347f4ce3d0fb5dc6e0926af83159037a3cf93a14b830250573a523d6ec405c238125e8979b
6
+ metadata.gz: 5c20cff52a8871e886ccaa192393b1c8b34675332ae4cad426bde9dbf19e15c3c613748215af0943503fd72e627ea8dbcbc598b734a2318f255e2dfa305b83ba
7
+ data.tar.gz: 41be55eb469a678708668864f8509d695d876a75ed5776596cc06ca1d81935b6a6ade0882ae2d7ef7fa03498217e5c4c808245673fbf05eddc32c5ce1edcbfb3
@@ -1,4 +1,5 @@
1
1
  module PatientZero
2
2
  class Error < StandardError; end
3
3
  class NotFoundError < Error; end
4
+ class InvalidPlatformError < Error; end
4
5
  end
@@ -28,6 +28,13 @@ module PatientZero
28
28
  raise NotFoundError, e
29
29
  end
30
30
 
31
+ def self.creation_url platform, token=Authorization.token, reference_id=nil
32
+ response = connection.get("/mobile/api/v1/sources/#{platform}/authenticate", client_token: token, reference_id: reference_id)
33
+ creation_url = response.headers.fetch :location
34
+ raise InvalidPlatformError, creation_url.split('error=').last if creation_url.include? 'error'
35
+ creation_url
36
+ end
37
+
31
38
  def platform_id
32
39
  id.split('#').last
33
40
  end
@@ -1,3 +1,3 @@
1
1
  module PatientZero
2
- VERSION = '0.5.7'
2
+ VERSION = '0.5.8'
3
3
  end
@@ -65,6 +65,29 @@ module PatientZero
65
65
  end
66
66
  end
67
67
 
68
+ describe '.creation_url' do
69
+ let(:platform) { 'facebook' }
70
+ let(:url) { 'http://something-something.dangerzone.com' }
71
+ let(:creation_url_response) { double :creation_url_response, headers: { location: url } }
72
+ before{ allow(Source.connection).to receive(:get).with("/mobile/api/v1/sources/#{platform}/authenticate", anything).and_return creation_url_response }
73
+ it 'calls the sources authentication api' do
74
+ expect(Source.connection).to receive(:get).with("/mobile/api/v1/sources/#{platform}/authenticate", anything)
75
+ Source.creation_url platform, token, 678
76
+ end
77
+ context 'when using a valid platform name' do
78
+ it 'returns the valid url' do
79
+ expect(Source.creation_url platform, token, 678).to eq url
80
+ end
81
+ end
82
+ context 'when using an invalid platform name' do
83
+ let(:platform) { 'myspace' }
84
+ let(:url) { '"https://app.viralheat.com?error=Invalid platform Myspace"' }
85
+ it 'raises an InvalidPlatformError' do
86
+ expect{Source.creation_url platform, token, 678}.to raise_error InvalidPlatformError
87
+ end
88
+ end
89
+ end
90
+
68
91
  describe '#platform_id' do
69
92
  it 'returns the number at the end of the id' do
70
93
  expect(source.platform_id).to eq '1234567890'
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.5.7
4
+ version: 0.5.8
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-05-07 00:00:00.000000000 Z
12
+ date: 2015-05-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler