ruby-everyoneapi 0.0.2
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 +7 -0
- data/.gitignore +22 -0
- data/Gemfile +5 -0
- data/LICENSE +21 -0
- data/LICENSE.txt +22 -0
- data/README.md +35 -0
- data/Rakefile +2 -0
- data/lib/everyoneapi/version.rb +3 -0
- data/lib/everyoneapi.rb +59 -0
- data/ruby-everyoneapi.gemspec +23 -0
- data/spec/lib/everyoneapi.rb +13 -0
- data/spec/spec_helper.rb +3 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 751999669d3d16df8ae21839934790151a9ef72a
|
4
|
+
data.tar.gz: a69ff4996ddbab10838264c3d5efb25aa45b286d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: de199d0896caea51e3a5d10863cc8fa77343e104019d85382c3ff02ca46c4710d551166cd83f8d24324acb045d17a371e183c9698c2a171d95d1e210329d9f72
|
7
|
+
data.tar.gz: f30f8f73891cda872a862b5b3a9822fa61c864c66b7d143f53afa26841f5c1451ad7afb35af472c8b333ae0d9d279cdbfe743ec7d9b4a11a8238d13325d1b551
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Venturit Inc
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Prabode Weebadde
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Ruby::Everyoneapi
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'ruby-everyoneapi'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install ruby-everyoneapi
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
Get person name by phone number
|
21
|
+
|
22
|
+
Everyoneapi.person("+15551234567").name
|
23
|
+
|
24
|
+
## Spec
|
25
|
+
Run spec
|
26
|
+
|
27
|
+
EVERYONEAPI_SID=XXXX EVERYONEAPI_TOKEN=XXXX be rspec spec/lib/everyoneapi.rb
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it ( https://github.com/[my-github-username]/ruby-everyoneapi/fork )
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/lib/everyoneapi.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
require "everyoneapi/version"
|
2
|
+
require "net/http"
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Everyoneapi
|
6
|
+
|
7
|
+
API_ENDPOINT = 'https://api.everyoneapi.com'
|
8
|
+
API_VERSION = 'v1'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
def person(phone_number)
|
13
|
+
options = {}
|
14
|
+
options[:data] = "name,address"
|
15
|
+
options[:account_sid] = ENV['EVERYONEAPI_SID']
|
16
|
+
options[:auth_token] = ENV['EVERYONEAPI_TOKEN']
|
17
|
+
|
18
|
+
url = [API_ENDPOINT, API_VERSION,"phone",phone_number.strip].join("/")
|
19
|
+
uri = URI.parse(url)
|
20
|
+
uri.query = URI.encode_www_form(options)
|
21
|
+
|
22
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
23
|
+
|
24
|
+
http.use_ssl = true
|
25
|
+
|
26
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
27
|
+
|
28
|
+
res = http.request(request)
|
29
|
+
|
30
|
+
raise Error.new res.message unless res.kind_of? Net::HTTPOK
|
31
|
+
|
32
|
+
return Person.new JSON.parse(res.body,:symbolize_names => true)
|
33
|
+
end
|
34
|
+
|
35
|
+
module_function :person
|
36
|
+
|
37
|
+
class Person
|
38
|
+
|
39
|
+
attr_accessor :name, :street, :city, :state, :zip, :latitude, :longitude
|
40
|
+
|
41
|
+
def initialize(options = {})
|
42
|
+
unless options[:data].nil?
|
43
|
+
@name = options[:data][:name]
|
44
|
+
@street = options[:data][:address]
|
45
|
+
unless options[:data][:location].nil?
|
46
|
+
@city = options[:data][:location][:city]
|
47
|
+
@state = options[:data][:location][:state]
|
48
|
+
@zip = options[:data][:location][:zip]
|
49
|
+
unless options[:data][:location][:geo].nil?
|
50
|
+
@latitude = options[:data][:location][:geo][:latitude]
|
51
|
+
@longitude = options[:data][:location][:geo][:longitude]
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'everyoneapi/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby-everyoneapi"
|
8
|
+
spec.version = Everyoneapi::VERSION
|
9
|
+
spec.authors = ["Prabode Weebadde"]
|
10
|
+
spec.email = ["prabode@venturit.com"]
|
11
|
+
spec.summary = %q{Ruby gem for EveryoneAPI}
|
12
|
+
spec.description = %q{Ruby gem for EveryoneAPI}
|
13
|
+
spec.homepage = "https://github.com/venturit/ruby-everyoneapi"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
|
4
|
+
describe Everyoneapi do
|
5
|
+
|
6
|
+
describe 'Everyoneapi' do
|
7
|
+
it 'should load the person name and address by phone number' do
|
8
|
+
expect(Everyoneapi.person("+15551234567").name).to eq "Michael Seaver"
|
9
|
+
expect(Everyoneapi.person("+15551234567").street).to eq "15 Robin Hood Lane"
|
10
|
+
expect(Everyoneapi.person("+15551234567").latitude).to eq "40.799787"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby-everyoneapi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Prabode Weebadde
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-10-01 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.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: Ruby gem for EveryoneAPI
|
42
|
+
email:
|
43
|
+
- prabode@venturit.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/everyoneapi.rb
|
55
|
+
- lib/everyoneapi/version.rb
|
56
|
+
- ruby-everyoneapi.gemspec
|
57
|
+
- spec/lib/everyoneapi.rb
|
58
|
+
- spec/spec_helper.rb
|
59
|
+
homepage: https://github.com/venturit/ruby-everyoneapi
|
60
|
+
licenses:
|
61
|
+
- MIT
|
62
|
+
metadata: {}
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '>='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubyforge_project:
|
79
|
+
rubygems_version: 2.4.2
|
80
|
+
signing_key:
|
81
|
+
specification_version: 4
|
82
|
+
summary: Ruby gem for EveryoneAPI
|
83
|
+
test_files:
|
84
|
+
- spec/lib/everyoneapi.rb
|
85
|
+
- spec/spec_helper.rb
|
86
|
+
has_rdoc:
|