responsys-api 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +20 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/lib/responsys/client.rb +64 -0
- data/lib/responsys/responsys_api.rb +39 -0
- data/lib/responsys_api.rb +1 -0
- data/responsys-api.gemspec +24 -0
- metadata +115 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0c3a10d995ca728b549d02f9de846a3b406f6425
|
4
|
+
data.tar.gz: 63cf563d0cf8e44b6770dc62c4c896741bf12617
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f98ddbc040040aa8b0aac236032a106d5c3b0ec238fdedcfd73fab0ff4e3f2f1148d09f3bd38cef6d540d9a1388233a671769b50e275ca9dbf5302d5d83a0b2
|
7
|
+
data.tar.gz: 35d99e84b5840eb90daee24d725fc0bf1aac3382efd750e6f93ae79a1e0aa083f3f2924bbc8cea45757e305ab3d3ccf68e7bd12e33f3e4b0463c0b92cee6744b
|
data/.gitignore
ADDED
@@ -0,0 +1,20 @@
|
|
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
|
+
.DS_Store
|
19
|
+
lib/.DS_Store
|
20
|
+
lib/responsys/.DS_Store
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Dan DeMeyere
|
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,29 @@
|
|
1
|
+
# Responsys::Api
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'responsys-api'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install responsys-api
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'version'
|
2
|
+
require 'responsys_helper'
|
3
|
+
require 'savon'
|
4
|
+
|
5
|
+
module ResponsysApi
|
6
|
+
class Client
|
7
|
+
###### Initialization/Session mgmt ######
|
8
|
+
def initialize(wsdl=nil, username=nil, password=nil)
|
9
|
+
#Get the settings
|
10
|
+
@wsdl = wsdl || ResponsysApi.wsdl || raise(ArgumentError, "You must provide a WSDL or call ResponsysApi.settings() first")
|
11
|
+
@username = username || ResponsysApi.username || raise(ArgumentError, "You must provide a username or call ResponsysApi.settings() first")
|
12
|
+
@password = password || ResponsysApi.password || raise(ArgumentError, "You must provide a password or call ResponsysApi.settings() first")
|
13
|
+
|
14
|
+
#Connection to the API with the credentials
|
15
|
+
@client = connect
|
16
|
+
end
|
17
|
+
|
18
|
+
#Set up the @client object used to call the api
|
19
|
+
def connect
|
20
|
+
sessionIds = login
|
21
|
+
@client = Savon.client(
|
22
|
+
wsdl: @wsdl,
|
23
|
+
soap_header: { "sessionHeader" => { "sessionId" => sessionIds["sessionId"] } },
|
24
|
+
headers: { "Cookie" => "JSESSIONID=#{sessionIds['jSessionId']}" },
|
25
|
+
element_form_default: :qualified
|
26
|
+
)
|
27
|
+
end
|
28
|
+
|
29
|
+
#Return the session ids required to identify the client
|
30
|
+
def login
|
31
|
+
temp_connection = Savon.client(wsdl: @wsdl,element_form_default: :qualified)
|
32
|
+
|
33
|
+
response = temp_connection.call(:login, message: { "username"=>@username,"password"=>@password })
|
34
|
+
|
35
|
+
result = ResponsysApi::Helper::get_result(response, 'login')
|
36
|
+
|
37
|
+
#Keep the Soap SessionId which is to be used in each soap header requests
|
38
|
+
sessionId = result[:session_id]
|
39
|
+
|
40
|
+
#Keep the JSESSIONID which is to be inserted in each HTTP header of soap requests
|
41
|
+
jSessionId = response.http.headers["set-cookie"][0].split(';')[0].partition('=')[2]
|
42
|
+
|
43
|
+
{"sessionId" => sessionId, "jSessionId" => jSessionId}
|
44
|
+
end
|
45
|
+
|
46
|
+
def logout
|
47
|
+
@client.call(:logout)
|
48
|
+
@client=nil
|
49
|
+
end
|
50
|
+
|
51
|
+
def connected?
|
52
|
+
!@client.nil?
|
53
|
+
end
|
54
|
+
###### End Initialization/Session mgmt ######
|
55
|
+
|
56
|
+
###### Folders ######
|
57
|
+
def listFolders
|
58
|
+
response = @client.call(:list_folders)
|
59
|
+
|
60
|
+
ResponsysApi::Helper::get_result(response, 'list_folders')
|
61
|
+
end
|
62
|
+
###### End Folders ######
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'savon'
|
2
|
+
|
3
|
+
class ResponsysApi
|
4
|
+
attr_accessor :client, :session_id, :jsession_id, :header
|
5
|
+
|
6
|
+
def initialize(username, password, wsdl)
|
7
|
+
@username = username
|
8
|
+
@password = password
|
9
|
+
@wsdl = wsdl
|
10
|
+
@client = SavonApi.new(wsdl)
|
11
|
+
login
|
12
|
+
end
|
13
|
+
|
14
|
+
def login
|
15
|
+
response = client.run("login", login_credentials)
|
16
|
+
establish_session_id(response)
|
17
|
+
establish_jsession_id(response)
|
18
|
+
set_session_credentials
|
19
|
+
response
|
20
|
+
end
|
21
|
+
|
22
|
+
def api_method(method_name, message)
|
23
|
+
client.run_with_credentials(method_name, message, jsession_id, header)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def establish_session_id(login_response)
|
29
|
+
@session_id = login_response.body[:login_response][:result][:session_id]
|
30
|
+
end
|
31
|
+
|
32
|
+
def establish_jsession_id(login_response)
|
33
|
+
@jsession_id = login_response.http.cookies[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
def set_session_credentials
|
37
|
+
@header = { "SessionHeader" => { "tns:sessionId" => session_id } }
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'responsys/responsys_api'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "responsys-api"
|
7
|
+
spec.version = "0.0.1"
|
8
|
+
spec.authors = ["Dan DeMeyere", "Florian Lorrain", "Morgan Griggs", "Mike Rocco"]
|
9
|
+
spec.email = ["dan@thredup.com", "florain.lorrain@thredup.com", "morgan@thredup.com", "michael.rocco@thredup.com"]
|
10
|
+
spec.description = 'A gem to integrate with the Responsys SOAP API'
|
11
|
+
spec.summary = 'Write a proper summary'
|
12
|
+
spec.homepage = "https://github.com/dandemeyere/responsys-api"
|
13
|
+
spec.license = "MIT"
|
14
|
+
|
15
|
+
spec.files = `git ls-files`.split($/)
|
16
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_dependency "savon", "~> 2.6.0"
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency 'rspec', '3.0.0'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: responsys-api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dan DeMeyere
|
8
|
+
- Florian Lorrain
|
9
|
+
- Morgan Griggs
|
10
|
+
- Mike Rocco
|
11
|
+
autorequire:
|
12
|
+
bindir: bin
|
13
|
+
cert_chain: []
|
14
|
+
date: 2014-08-08 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: savon
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.6.0
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.6.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ~>
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '1.3'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '1.3'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rake
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - '>='
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rspec
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 3.0.0
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 3.0.0
|
72
|
+
description: A gem to integrate with the Responsys SOAP API
|
73
|
+
email:
|
74
|
+
- dan@thredup.com
|
75
|
+
- florain.lorrain@thredup.com
|
76
|
+
- morgan@thredup.com
|
77
|
+
- michael.rocco@thredup.com
|
78
|
+
executables: []
|
79
|
+
extensions: []
|
80
|
+
extra_rdoc_files: []
|
81
|
+
files:
|
82
|
+
- .gitignore
|
83
|
+
- Gemfile
|
84
|
+
- LICENSE.txt
|
85
|
+
- README.md
|
86
|
+
- Rakefile
|
87
|
+
- lib/responsys/client.rb
|
88
|
+
- lib/responsys/responsys_api.rb
|
89
|
+
- lib/responsys_api.rb
|
90
|
+
- responsys-api.gemspec
|
91
|
+
homepage: https://github.com/dandemeyere/responsys-api
|
92
|
+
licenses:
|
93
|
+
- MIT
|
94
|
+
metadata: {}
|
95
|
+
post_install_message:
|
96
|
+
rdoc_options: []
|
97
|
+
require_paths:
|
98
|
+
- lib
|
99
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
requirements: []
|
110
|
+
rubyforge_project:
|
111
|
+
rubygems_version: 2.0.14
|
112
|
+
signing_key:
|
113
|
+
specification_version: 4
|
114
|
+
summary: Write a proper summary
|
115
|
+
test_files: []
|