norada_solve_360 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +51 -0
- data/Rakefile +2 -0
- data/lib/norada_solve_360.rb +5 -0
- data/lib/norada_solve_360/api.rb +129 -0
- data/lib/norada_solve_360/version.rb +3 -0
- data/norada-solve360.gemspec +20 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c6fc86898f202ecb26ed6ec319363265c9aad09
|
4
|
+
data.tar.gz: b5840623d026a661467d609dc0c198514984670b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e203b4ceebfd51eebd78fe7378dc182c3718b39b0d5100a4953519fc0b6b1a7a53f1afafb7208a99c169772fa60061f749baffa8fedf9e5fb12d65fb37054451
|
7
|
+
data.tar.gz: 0cc999f074ba49c3472a733d33e811520cccba5a4f7c0f23e1048f04f935df58e2edeef1f335fa0a3932f38283d0b08777989f33d55726305da1d1bc355cdad8
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Invokevoke Inc
|
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,51 @@
|
|
1
|
+
# Norada::Solve360
|
2
|
+
|
3
|
+
gem 'norada_solve360', '~> 1.0.5'
|
4
|
+
|
5
|
+
TODO: Write a gem description
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'norada_solve360'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install norada_solve360
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
Connect to Norada
|
26
|
+
|
27
|
+
norada_api = NoradaSOLVE360::API.new('api_key', 'username')
|
28
|
+
|
29
|
+
Finders
|
30
|
+
|
31
|
+
members = norada_api.find_contacts(:all, {:layout => 1, :limit => "#{count}", :filtermode => 'category', :filtervalue => norada_category_id })
|
32
|
+
|
33
|
+
norada_api.find_contacts_categories(:all)
|
34
|
+
|
35
|
+
norada_api.find_contacts(norada_contact_id)
|
36
|
+
|
37
|
+
Create & Update
|
38
|
+
|
39
|
+
tag_vars = {categories: {add: ['tag-a', 'tag-b']}}
|
40
|
+
|
41
|
+
norada_api.update_contacts(norada_contact_id, tag_vars)
|
42
|
+
|
43
|
+
norada_api.create_contacts_categories({:name => 'name'})
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
1. Fork it ( https://github.com/[my-github-username]/norada-solve360/fork )
|
48
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
49
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
50
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
51
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
require 'rest_client'
|
2
|
+
require 'json'
|
3
|
+
require 'cgi'
|
4
|
+
|
5
|
+
|
6
|
+
module NoradaSOLVE360
|
7
|
+
|
8
|
+
class API
|
9
|
+
|
10
|
+
attr_accessor :user_api_token, :user_email, :norada_solve_url
|
11
|
+
|
12
|
+
|
13
|
+
def initialize(user_api_token, user_email)
|
14
|
+
@norada_solve_url = 'https://secure.solve360.com/'
|
15
|
+
@user_api_token = user_api_token
|
16
|
+
@user_email = user_email
|
17
|
+
end
|
18
|
+
|
19
|
+
def method_missing(method_name, *args)
|
20
|
+
if method_name.to_s =~ /^find_(.+)$/
|
21
|
+
find_method($1, *args)
|
22
|
+
elsif method_name.to_s =~ /^update_(.+)$/
|
23
|
+
update_method($1, *args)
|
24
|
+
elsif method_name.to_s =~ /^create_(.+)$/
|
25
|
+
create_method($1, *args)
|
26
|
+
elsif method_name.to_s =~ /^delete_(.+)$/
|
27
|
+
delete_method($1, *args)
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def call(method, method_url, params = {})
|
34
|
+
begin
|
35
|
+
m_url = norada_solve_url
|
36
|
+
m_url += method_url unless method.eql?(:put)
|
37
|
+
|
38
|
+
resource = RestClient::Resource.new m_url, :user => user_email, :password => user_api_token
|
39
|
+
|
40
|
+
if method == :get
|
41
|
+
response_obj = resource.get :accept => 'application/json', :params => params
|
42
|
+
elsif method == :put
|
43
|
+
response_obj = resource[method_url].put params, :accept => 'application/json'
|
44
|
+
elsif method == :post
|
45
|
+
response_obj = resource.post params, :accept => 'application/json'
|
46
|
+
elsif method == :delete
|
47
|
+
response_obj = resource.delete :accept => 'application/json'
|
48
|
+
end
|
49
|
+
rescue Exception => e
|
50
|
+
raise "#{e}"
|
51
|
+
end
|
52
|
+
|
53
|
+
return JSON.parse response_obj
|
54
|
+
end
|
55
|
+
|
56
|
+
def method_url(method_name)
|
57
|
+
method_components = method_name.to_s.split(/_/)
|
58
|
+
murl = method_components.shift
|
59
|
+
if method_components.size > 0
|
60
|
+
murl += '/' + method_components.join('_')
|
61
|
+
end
|
62
|
+
|
63
|
+
murl
|
64
|
+
end
|
65
|
+
|
66
|
+
def update_method(method_name, *args)
|
67
|
+
murl = method_url(method_name)
|
68
|
+
|
69
|
+
arg = args[0]
|
70
|
+
|
71
|
+
raise "Argument must be a number" if (!arg.is_a? Integer)
|
72
|
+
|
73
|
+
murl += "/#{arg}"
|
74
|
+
arg = args[1]
|
75
|
+
|
76
|
+
call(:put, murl, arg)
|
77
|
+
end
|
78
|
+
|
79
|
+
def create_method(method_name, *args)
|
80
|
+
murl = method_url(method_name)
|
81
|
+
|
82
|
+
arg = args[0]
|
83
|
+
|
84
|
+
raise "Argument must be a hash" if (!arg.is_a? Hash)
|
85
|
+
|
86
|
+
call(:post, murl, arg)
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
def delete_method(method_name, *args)
|
91
|
+
murl = method_url(method_name)
|
92
|
+
|
93
|
+
arg = args[0]
|
94
|
+
|
95
|
+
raise "Argument must be a number" if (!arg.is_a? Integer)
|
96
|
+
|
97
|
+
murl += "/#{arg}"
|
98
|
+
arg = args[1]
|
99
|
+
|
100
|
+
call(:delete, murl, arg)
|
101
|
+
end
|
102
|
+
|
103
|
+
def find_method(method_name, *args)
|
104
|
+
murl = method_url(method_name)
|
105
|
+
|
106
|
+
arg = args[0]
|
107
|
+
|
108
|
+
if (!arg.is_a? Symbol) and (!arg.is_a? Integer)
|
109
|
+
raise "Argument must be a :all or number"
|
110
|
+
end
|
111
|
+
|
112
|
+
if arg == :all
|
113
|
+
murl
|
114
|
+
else
|
115
|
+
murl += "/#{arg}"
|
116
|
+
end
|
117
|
+
|
118
|
+
arg = args[1]
|
119
|
+
|
120
|
+
call(:get, murl, arg)
|
121
|
+
end
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
end
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/norada_solve_360/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Bernard Otu"]
|
6
|
+
gem.email = ["phyxavier@gmail.com"]
|
7
|
+
gem.description = %q{Library for accessing Norada Solve 360 REST API.}
|
8
|
+
gem.summary = %q{Library for accessing Norada Solve 360 REST API.}
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "norada_solve_360"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = NoradaSolve360::VERSION
|
16
|
+
gem.add_dependency("json")
|
17
|
+
gem.add_dependency("rest-client")
|
18
|
+
gem.add_development_dependency "bundler", "~> 1.7"
|
19
|
+
gem.add_development_dependency "rake", "~> 10.0"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: norada_solve_360
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Bernard Otu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.7'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.7'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description: Library for accessing Norada Solve 360 REST API.
|
70
|
+
email:
|
71
|
+
- phyxavier@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- Gemfile
|
78
|
+
- LICENSE
|
79
|
+
- README.md
|
80
|
+
- Rakefile
|
81
|
+
- lib/norada_solve_360.rb
|
82
|
+
- lib/norada_solve_360/api.rb
|
83
|
+
- lib/norada_solve_360/version.rb
|
84
|
+
- norada-solve360.gemspec
|
85
|
+
homepage:
|
86
|
+
licenses: []
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.4.5
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Library for accessing Norada Solve 360 REST API.
|
108
|
+
test_files: []
|