creatary-sdk 1.3.1 → 1.4.0
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.
- data/README.mkd +10 -6
- data/creatary-sdk.gemspec +1 -2
- data/lib/creatary/api.rb +1 -0
- data/lib/creatary/api/lifecycle.rb +38 -0
- data/lib/creatary/api/oauth.rb +10 -2
- data/lib/creatary/version.rb +1 -1
- metadata +26 -22
data/README.mkd
CHANGED
@@ -24,9 +24,9 @@ If you are using rails then:
|
|
24
24
|
|
25
25
|
```yaml
|
26
26
|
development: &defaults
|
27
|
-
consumer_key: # the consumer key generated in
|
28
|
-
consumer_secret: # the consumer secret generated in
|
29
|
-
consumer_handler: # the of the class that implements the
|
27
|
+
consumer_key: # the consumer key generated in creatary.com for you application
|
28
|
+
consumer_secret: # the consumer secret generated in creatary.com for you application
|
29
|
+
consumer_handler: # the of the class that implements the creatary handler logic
|
30
30
|
test:
|
31
31
|
<<: *defaults
|
32
32
|
production:
|
@@ -53,6 +53,9 @@ If you are using rails then:
|
|
53
53
|
|
54
54
|
def receive_sms(from_user, to_app, body)
|
55
55
|
end
|
56
|
+
|
57
|
+
def lifecycle_notification(channel, invoker, reason, application_name, notification_type, access_tokens)
|
58
|
+
end
|
56
59
|
|
57
60
|
end
|
58
61
|
```
|
@@ -60,7 +63,8 @@ If you are using rails then:
|
|
60
63
|
5. The routes exposed by the gem in your rails application are:
|
61
64
|
|
62
65
|
```ruby
|
63
|
-
/creatary/authorize
|
64
|
-
/creatary/receive_sms
|
65
|
-
/creatary/oauth_callback
|
66
|
+
/creatary/authorize # redirect to this one when you want to initiate the OAUTH authorization flow (pass ?subscription_tariff_name='' parameter to the redirect when performing subscription authorization OAUTH flow)
|
67
|
+
/creatary/receive_sms # use this one (complement to form absolute path) as SMS URL when registering your application in creatary.com
|
68
|
+
/creatary/oauth_callback # use this one (complement to form absolute path) as OAUTH callback URL when registering your application in creatary.com
|
69
|
+
/creatary/lifecycle_callback # use this one (complement to form absolute path) as subscriber lifecycle callback URL when registering your application in creatary.com
|
66
70
|
```
|
data/creatary-sdk.gemspec
CHANGED
@@ -37,8 +37,7 @@ Gem::Specification.new do |s|
|
|
37
37
|
Creatary:
|
38
38
|
https://creatary.com/
|
39
39
|
Notice that in order to use this gem you will also need to register as a
|
40
|
-
developer in Creatary
|
41
|
-
https://telcoassetmarketplace.com
|
40
|
+
developer in Creatary
|
42
41
|
|
43
42
|
********************************************************************************
|
44
43
|
eos
|
data/lib/creatary/api.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'sinatra'
|
2
|
+
require 'oauth'
|
3
|
+
require 'json'
|
4
|
+
require 'creatary/user'
|
5
|
+
|
6
|
+
# Lifecycle part of the Creatary REST API
|
7
|
+
module Creatary
|
8
|
+
class API
|
9
|
+
# URL handler for receiving lifecycle notifications
|
10
|
+
# After receiving a lifecycle notification, the configured
|
11
|
+
# consumer_handler.lifecycle_notification(channel, invoker, reason,
|
12
|
+
# applicationName, notificationType, accessTokens)
|
13
|
+
# is invoked
|
14
|
+
#
|
15
|
+
# @private
|
16
|
+
post "/*/lifecycle_callback" do
|
17
|
+
request.body.rewind # in case someone already read it
|
18
|
+
|
19
|
+
data = JSON.parse request.body.read
|
20
|
+
|
21
|
+
channel = data["channel"]
|
22
|
+
invoker = data["invoker"]
|
23
|
+
reason = data["reason"]
|
24
|
+
application_name = data["applicationName"]
|
25
|
+
notification_type = data["notificationType"]
|
26
|
+
access_tokens = data["accessTokens"]
|
27
|
+
|
28
|
+
begin
|
29
|
+
dispatch_to_handler('lifecycle_notification', channel, invoker, reason, application_name, notification_type, access_tokens)
|
30
|
+
response.status = 200
|
31
|
+
return ''
|
32
|
+
rescue Error => error
|
33
|
+
response.status = 500
|
34
|
+
return error.message
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/lib/creatary/api/oauth.rb
CHANGED
@@ -17,7 +17,11 @@ module Creatary
|
|
17
17
|
session[:request_token] = request_token
|
18
18
|
|
19
19
|
oauth_callback_url = url('/' + Creatary.callback_path + '/oauth_callback')
|
20
|
-
|
20
|
+
if params[:subscription_tariff_name].nil?
|
21
|
+
redirect request_token.authorize_url(:oauth_callback => oauth_callback_url)
|
22
|
+
else
|
23
|
+
redirect request_token.authorize_url(:oauth_callback => oauth_callback_url, :subscription_tariff_name => params[:subscription_tariff_name])
|
24
|
+
end
|
21
25
|
end
|
22
26
|
|
23
27
|
# OAUTH callback for Creatary
|
@@ -29,7 +33,11 @@ module Creatary
|
|
29
33
|
verifier = params[:oauth_verifier]
|
30
34
|
access_token = request_token.get_access_token(:oauth_verifier => verifier)
|
31
35
|
user = User.new(access_token.token, access_token.secret)
|
32
|
-
|
36
|
+
if params[:subscription_tariff_name].nil?
|
37
|
+
redirect url(dispatch_to_handler('authorized', user, session))
|
38
|
+
else
|
39
|
+
redirect url(dispatch_to_handler('authorized', user, session, params[:subscription_tariff_name]))
|
40
|
+
end
|
33
41
|
else
|
34
42
|
redirect url(dispatch_to_handler('denied', session))
|
35
43
|
end
|
data/lib/creatary/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: creatary-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01
|
12
|
+
date: 2012-03-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sinatra
|
16
|
-
requirement: &
|
16
|
+
requirement: &2152965340 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 1.2.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2152965340
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: json
|
27
|
-
requirement: &
|
27
|
+
requirement: &2152963440 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.5'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2152963440
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: oauth
|
38
|
-
requirement: &
|
38
|
+
requirement: &2152962460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.4.3
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2152962460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &2152961360 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - =
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 0.9.2
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2152961360
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rspec
|
60
|
-
requirement: &
|
60
|
+
requirement: &2152960480 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - =
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: 1.3.2
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2152960480
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rack-test
|
71
|
-
requirement: &
|
71
|
+
requirement: &2152959200 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.6.1
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2152959200
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: mocha
|
82
|
-
requirement: &
|
82
|
+
requirement: &2152958240 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: 0.9.0
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2152958240
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: webmock
|
93
|
-
requirement: &
|
93
|
+
requirement: &2152957620 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: 1.7.0
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2152957620
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: simplecov
|
104
|
-
requirement: &
|
104
|
+
requirement: &2152957040 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ~>
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: 0.5.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2152957040
|
113
113
|
description: The Ruby gem for the Creatary REST APIs
|
114
114
|
email:
|
115
115
|
- developers@creatary.com
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/creatary-sdk.rb
|
127
127
|
- lib/creatary/api.rb
|
128
128
|
- lib/creatary/api/charging.rb
|
129
|
+
- lib/creatary/api/lifecycle.rb
|
129
130
|
- lib/creatary/api/location.rb
|
130
131
|
- lib/creatary/api/oauth.rb
|
131
132
|
- lib/creatary/api/sms.rb
|
@@ -146,7 +147,7 @@ licenses: []
|
|
146
147
|
post_install_message: ! "********************************************************************************\n\n
|
147
148
|
\ Visit our community pages for up-to-date information on \n Creatary:\n https://creatary.com/\n
|
148
149
|
\ Notice that in order to use this gem you will also need to register as a \n developer
|
149
|
-
in Creatary
|
150
|
+
in Creatary\n\n********************************************************************************
|
150
151
|
\ \n"
|
151
152
|
rdoc_options: []
|
152
153
|
require_paths:
|
@@ -157,6 +158,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
157
158
|
- - ! '>='
|
158
159
|
- !ruby/object:Gem::Version
|
159
160
|
version: '0'
|
161
|
+
segments:
|
162
|
+
- 0
|
163
|
+
hash: -892372572178664446
|
160
164
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
161
165
|
none: false
|
162
166
|
requirements:
|
@@ -165,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
165
169
|
version: 1.3.6
|
166
170
|
requirements: []
|
167
171
|
rubyforge_project: creatary-sdk
|
168
|
-
rubygems_version: 1.8.
|
172
|
+
rubygems_version: 1.8.17
|
169
173
|
signing_key:
|
170
174
|
specification_version: 3
|
171
175
|
summary: Creatary Ruby gem
|