agra_api 0.1.1 → 0.2.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: 9ac0c26056912923bf02974a8ece99bf0a31c8b6
4
- data.tar.gz: 9df5c4852808a46a609efb075a213ea4a0c17c73
3
+ metadata.gz: c815e94e76c281bff34fd6da1fe4fd0ab3a6d8c8
4
+ data.tar.gz: 0019ffd02ebef5bf09f6a4998f4a9e0cfb147d2a
5
5
  SHA512:
6
- metadata.gz: e888751771de335d12337183e89cecc0d8fe805b54cf4a732928b3a922101abf084b6b3000d11eae8b6e54bca83291914693003497d09a749fd4fcaa1ae02008
7
- data.tar.gz: b23dd978866e39a0e14d2ba9af56d32acaa9b841f35442250261fe80ef8c65588d0eb3d884638513ce904e4f8c6533b39ae3f93c9d7eb1ab56d621c8914e62b8
6
+ metadata.gz: 2e52edfc72ecb8dcad6101f625e2436c8b14938adbf04daf14f7b824bd28534b66beb29fb7a4e14ef7c33a526d639e4cfb540a3f537551f01268adca88967c5a
7
+ data.tar.gz: 3b28fd9ad2b60f97103f98ac7a05854a9430de6c12d0c9071cad78fce79229c0d45b6ebd25ba63e8f5f0f84c1f8704f48245a9e416d2ca36e7db4dc59eb61194
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.0.0-p645
1
+ 2.2.4
data/Gemfile CHANGED
@@ -9,5 +9,5 @@ group :development do
9
9
  gem 'pry'
10
10
  gem 'pry-byebug'
11
11
  gem "bundler"
12
- gem "jeweler"
12
+ gem "juwelier", "~> 2.1.0"
13
13
  end
data/Gemfile.lock CHANGED
@@ -24,8 +24,8 @@ GEM
24
24
  multipart-post (>= 1.2, < 3)
25
25
  faraday_middleware (0.10.0)
26
26
  faraday (>= 0.7.4, < 0.10)
27
- git (1.2.9.1)
28
- github_api (0.12.4)
27
+ git (1.3.0)
28
+ github_api (0.13.0)
29
29
  addressable (~> 2.3)
30
30
  descendants_tracker (~> 0.0.4)
31
31
  faraday (~> 0.8, < 0.10)
@@ -34,9 +34,10 @@ GEM
34
34
  nokogiri (~> 1.6.6)
35
35
  oauth2
36
36
  hashie (3.4.2)
37
- highline (1.7.7)
37
+ highline (1.7.8)
38
38
  i18n (0.7.0)
39
- jeweler (2.0.1)
39
+ json (1.8.3)
40
+ juwelier (2.1.2)
40
41
  builder
41
42
  bundler (>= 1.0)
42
43
  git (>= 1.2.5)
@@ -45,22 +46,24 @@ GEM
45
46
  nokogiri (>= 1.5.10)
46
47
  rake
47
48
  rdoc
48
- json (1.8.3)
49
- jwt (1.5.1)
49
+ semver
50
+ jwt (1.5.4)
50
51
  method_source (0.8.2)
51
- mini_portile (0.6.2)
52
+ mini_portile2 (2.1.0)
52
53
  minitest (5.8.1)
53
- multi_json (1.11.2)
54
+ multi_json (1.12.1)
54
55
  multi_xml (0.5.5)
55
56
  multipart-post (2.0.0)
56
- nokogiri (1.6.6.2)
57
- mini_portile (~> 0.6.0)
58
- oauth2 (1.0.0)
57
+ nokogiri (1.6.8)
58
+ mini_portile2 (~> 2.1.0)
59
+ pkg-config (~> 1.1.7)
60
+ oauth2 (1.2.0)
59
61
  faraday (>= 0.8, < 0.10)
60
62
  jwt (~> 1.0)
61
63
  multi_json (~> 1.3)
62
64
  multi_xml (~> 0.5)
63
- rack (~> 1.2)
65
+ rack (>= 1.2, < 3)
66
+ pkg-config (1.1.7)
64
67
  pry (0.9.12.2)
65
68
  coderay (~> 1.0.5)
66
69
  method_source (~> 0.8)
@@ -68,9 +71,9 @@ GEM
68
71
  pry-byebug (1.3.2)
69
72
  byebug (~> 2.7)
70
73
  pry (~> 0.9.12)
71
- rack (1.6.4)
72
- rake (10.4.2)
73
- rdoc (4.2.0)
74
+ rack (2.0.1)
75
+ rake (11.2.2)
76
+ rdoc (4.2.2)
74
77
  json (~> 1.4)
75
78
  rspec (3.3.0)
76
79
  rspec-core (~> 3.3.0)
@@ -86,6 +89,7 @@ GEM
86
89
  rspec-support (~> 3.3.0)
87
90
  rspec-support (3.3.0)
88
91
  safe_yaml (0.9.7)
92
+ semver (1.0.1)
89
93
  slop (3.4.6)
90
94
  thread_safe (0.3.5)
91
95
  tzinfo (1.2.2)
@@ -104,7 +108,7 @@ PLATFORMS
104
108
 
105
109
  DEPENDENCIES
106
110
  bundler
107
- jeweler
111
+ juwelier (~> 2.1.0)
108
112
  pry
109
113
  pry-byebug
110
114
  rspec
@@ -112,4 +116,4 @@ DEPENDENCIES
112
116
  webmock
113
117
 
114
118
  BUNDLED WITH
115
- 1.10.6
119
+ 1.12.5
data/Rakefile CHANGED
@@ -11,13 +11,10 @@ rescue Bundler::BundlerError => e
11
11
  end
12
12
  require 'rake'
13
13
 
14
- require './lib/agra_api/version.rb'
15
-
16
- require 'jeweler'
17
- Jeweler::Tasks.new do |gem|
14
+ require 'juwelier'
15
+ Juwelier::Tasks.new do |gem|
18
16
  # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
19
17
  gem.name = "agra_api"
20
- gem.version = AgraApi::VERSION::STRING
21
18
  gem.homepage = "http://github.com/controlshift/agra_api"
22
19
  gem.license = "MIT"
23
20
  gem.summary = "A very basic agra client gem"
@@ -26,7 +23,7 @@ Jeweler::Tasks.new do |gem|
26
23
  gem.authors = ["Nathan Woodhull"]
27
24
  # dependencies defined in Gemfile
28
25
  end
29
- Jeweler::RubygemsDotOrgTasks.new
26
+ Juwelier::RubygemsDotOrgTasks.new
30
27
 
31
28
  require 'rspec/core'
32
29
  require 'rspec/core/rake_task'
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.0
data/agra_api.gemspec CHANGED
@@ -1,17 +1,17 @@
1
- # Generated by jeweler
1
+ # Generated by juwelier
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
3
+ # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: agra_api 0.1.1 ruby lib
5
+ # stub: agra_api 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "agra_api"
9
- s.version = "0.1.1"
9
+ s.version = "0.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Nathan Woodhull"]
14
- s.date = "2015-10-02"
14
+ s.date = "2016-08-24"
15
15
  s.description = "Agra is a distributed petitions platform, this is a gem for talking to it's API"
16
16
  s.email = "nathan@controlshiftlabs.com"
17
17
  s.extra_rdoc_files = [
@@ -28,16 +28,18 @@ Gem::Specification.new do |s|
28
28
  "LICENSE.txt",
29
29
  "README.rdoc",
30
30
  "Rakefile",
31
+ "VERSION",
31
32
  "agra_api.gemspec",
32
33
  "lib/agra_api.rb",
33
34
  "lib/agra_api/base.rb",
34
35
  "lib/agra_api/client.rb",
35
36
  "lib/agra_api/organisation.rb",
36
- "lib/agra_api/version.rb",
37
+ "lib/agra_api/signature.rb",
37
38
  "spec/agra_api_spec.rb",
38
39
  "spec/client_spec.rb",
39
40
  "spec/fixtures/organisation.json",
40
41
  "spec/organisation_spec.rb",
42
+ "spec/signature_spec.rb",
41
43
  "spec/spec_helper.rb"
42
44
  ]
43
45
  s.homepage = "http://github.com/controlshift/agra_api"
@@ -55,7 +57,7 @@ Gem::Specification.new do |s|
55
57
  s.add_development_dependency(%q<pry>, [">= 0"])
56
58
  s.add_development_dependency(%q<pry-byebug>, [">= 0"])
57
59
  s.add_development_dependency(%q<bundler>, [">= 0"])
58
- s.add_development_dependency(%q<jeweler>, [">= 0"])
60
+ s.add_development_dependency(%q<juwelier>, ["~> 2.1.0"])
59
61
  else
60
62
  s.add_dependency(%q<vertebrae>, [">= 0"])
61
63
  s.add_dependency(%q<rspec>, [">= 0"])
@@ -63,7 +65,7 @@ Gem::Specification.new do |s|
63
65
  s.add_dependency(%q<pry>, [">= 0"])
64
66
  s.add_dependency(%q<pry-byebug>, [">= 0"])
65
67
  s.add_dependency(%q<bundler>, [">= 0"])
66
- s.add_dependency(%q<jeweler>, [">= 0"])
68
+ s.add_dependency(%q<juwelier>, ["~> 2.1.0"])
67
69
  end
68
70
  else
69
71
  s.add_dependency(%q<vertebrae>, [">= 0"])
@@ -72,7 +74,7 @@ Gem::Specification.new do |s|
72
74
  s.add_dependency(%q<pry>, [">= 0"])
73
75
  s.add_dependency(%q<pry-byebug>, [">= 0"])
74
76
  s.add_dependency(%q<bundler>, [">= 0"])
75
- s.add_dependency(%q<jeweler>, [">= 0"])
77
+ s.add_dependency(%q<juwelier>, ["~> 2.1.0"])
76
78
  end
77
79
  end
78
80
 
@@ -1,7 +1,11 @@
1
1
  module AgraApi
2
2
  class Client < Vertebrae::API
3
3
  def organisation
4
- @user ||= AgraApi::Organisation.new(client: self)
4
+ @organisation ||= AgraApi::Organisation.new(client: self)
5
+ end
6
+
7
+ def signature(petition_id)
8
+ @signature ||= AgraApi::Signature.new(client: self, petition_id: petition_id)
5
9
  end
6
10
 
7
11
  def default_options
@@ -0,0 +1,14 @@
1
+ module AgraApi
2
+ class Signature < Base
3
+ attr_accessor :petition_id
4
+
5
+ def base_path
6
+ "/petitions/#{petition_id}/signatures"
7
+ end
8
+
9
+ def find_by_email(email_address)
10
+ response = client.get_request("#{normalized_base_path}/lookup", email: email_address)
11
+ response.body
12
+ end
13
+ end
14
+ end
data/lib/agra_api.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'vertebrae'
2
2
  require 'agra_api/base'
3
3
  require 'agra_api/organisation'
4
+ require 'agra_api/signature'
4
5
  require 'agra_api/client'
5
6
 
6
7
  module AgraApi
@@ -0,0 +1,28 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe AgraApi::Signature do
4
+ let(:petition_id) { 999 }
5
+ let(:email_address) { 'pedro@test.com' }
6
+
7
+ subject { AgraApi.new(host: 'test.com', username: 'username', password: 'password').signature(petition_id) }
8
+
9
+ describe 'configuration' do
10
+ it 'should propagate the host' do
11
+ expect(subject.client.connection.configuration.host).to eq('test.com')
12
+ end
13
+ end
14
+
15
+ describe '#find_by_email' do
16
+ it 'should perform lookup on agra' do
17
+ stub_request(:get, "https://username:password@test.com/api/petitions/#{petition_id}/signatures/lookup?email=#{email_address}")
18
+ .to_return(:body => {id: 1000, email: email_address}.to_json, :status => 200,
19
+ :headers => { content_type: "application/json; charset=utf-8"})
20
+
21
+ signature = subject.find_by_email(email_address)
22
+
23
+ expect(signature).not_to be_nil
24
+ expect(signature.id).to eq 1000
25
+ expect(signature.email).to eq email_address
26
+ end
27
+ end
28
+ end
metadata CHANGED
@@ -1,113 +1,113 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agra_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Woodhull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-02 00:00:00.000000000 Z
11
+ date: 2016-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vertebrae
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: webmock
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry-byebug
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: bundler
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: jeweler
98
+ name: juwelier
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 2.1.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 2.1.0
111
111
  description: Agra is a distributed petitions platform, this is a gem for talking to
112
112
  it's API
113
113
  email: nathan@controlshiftlabs.com
@@ -117,25 +117,27 @@ extra_rdoc_files:
117
117
  - LICENSE.txt
118
118
  - README.rdoc
119
119
  files:
120
- - .document
121
- - .rspec
122
- - .ruby-gemset
123
- - .ruby-version
120
+ - ".document"
121
+ - ".rspec"
122
+ - ".ruby-gemset"
123
+ - ".ruby-version"
124
124
  - Gemfile
125
125
  - Gemfile.lock
126
126
  - LICENSE.txt
127
127
  - README.rdoc
128
128
  - Rakefile
129
+ - VERSION
129
130
  - agra_api.gemspec
130
131
  - lib/agra_api.rb
131
132
  - lib/agra_api/base.rb
132
133
  - lib/agra_api/client.rb
133
134
  - lib/agra_api/organisation.rb
134
- - lib/agra_api/version.rb
135
+ - lib/agra_api/signature.rb
135
136
  - spec/agra_api_spec.rb
136
137
  - spec/client_spec.rb
137
138
  - spec/fixtures/organisation.json
138
139
  - spec/organisation_spec.rb
140
+ - spec/signature_spec.rb
139
141
  - spec/spec_helper.rb
140
142
  homepage: http://github.com/controlshift/agra_api
141
143
  licenses:
@@ -147,12 +149,12 @@ require_paths:
147
149
  - lib
148
150
  required_ruby_version: !ruby/object:Gem::Requirement
149
151
  requirements:
150
- - - '>='
152
+ - - ">="
151
153
  - !ruby/object:Gem::Version
152
154
  version: '0'
153
155
  required_rubygems_version: !ruby/object:Gem::Requirement
154
156
  requirements:
155
- - - '>='
157
+ - - ">="
156
158
  - !ruby/object:Gem::Version
157
159
  version: '0'
158
160
  requirements: []
@@ -1,10 +0,0 @@
1
- module AgraApi
2
- module VERSION
3
- MAJOR = 0
4
- MINOR = 1
5
- PATCH = 1
6
- BUILD = nil
7
-
8
- STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
9
- end
10
- end