idn_sdk_ruby 0.1.1 → 0.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e823be66b069a5c74cf8cd229edb7cb198e1b152
4
- data.tar.gz: 5f4ef544e1201c040b96cf1ada5c05802f6a1cfa
3
+ metadata.gz: 9f31d370461c8d1e6ab6585a45d9f3da376bdbd1
4
+ data.tar.gz: f7a7613d1d97577ddeeb8a189b590ddc15b06329
5
5
  SHA512:
6
- metadata.gz: e739f9c9105273d1ed84cdbfc4e7523bd7d0d2a0f9493005df91e9211099ce0de5012093288ad6846e417efc4860d903149573dd35470b7495e70d099e8c39aa
7
- data.tar.gz: cf016f459e5acbd4cefabab1a53338dcaa08cdb0f3b2088b8d860b835f6f0d873eadcbaa9115c38232d42dbf52ee78daf4f8cbf65c4f83d80ddcb31f7ece44fe
6
+ metadata.gz: 6f64128fbd7fc164652615a931bb6cf8b97291205cf77e74ff96fe24507a95a6f541eb8cb0529753be533a076910487a0f98fd8a161611df6f205378a4b5c097
7
+ data.tar.gz: 553566ed579efd81a32816458e5ac487646001fffe61d5caf2f6228c98e5200f44fb9fbff6a4854cb832a85b2eb4a7cf42a51ad679f5c087afb1c34f780464d8
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # IdnSdkRuby
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/idn_sdk_ruby`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Welcome to Wavelabs idn_sdk_ruby gem. This gem is a simple wrapper to connect Wavelabs identity & media modules API.
6
4
 
7
5
  ## Installation
8
6
 
@@ -20,9 +18,122 @@ Or install it yourself as:
20
18
 
21
19
  $ gem install idn_sdk_ruby
22
20
 
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
21
+ # Usage
22
+ ## Rails Usage:
23
+ Once you Created a Rails application & installed the idn_sdk_ruby using bundle,
24
+ 1. Create a file which will maintain the ENV variables for IDN Modules Credentials & Social Provider Credentials as follows:
25
+
26
+ ```ruby
27
+ # Add configuration values here
28
+ FACEBOOK_KEY: "KEY"
29
+ FACEBOOK_SECRET: "SECRET"
30
+ GOOGLE_KEY: "KEY"
31
+ GOOGLE_SECRET: "SECRET"
32
+ GITHUB_KEY: "KEY"
33
+ GITHUB_SECRET: "SECRET"
34
+ TWITTER_KEY: "KEY"
35
+ TWITTER_SECRET: "SECRET"
36
+ LINKEDIN_KEY: "KEY"
37
+ LINKEDIN_SECRET: "SECRET"
38
+ INSTAGRAM_KEY: "KEY"
39
+ INSTAGRAM_SECRET: "SECRET"
40
+
41
+ MODULE_IDENTITY_API_HOST_URL: "http://api.qa1.nbos.in"
42
+ MODULE_IDENTITY_API_CLIENT_KEY: "sample-app-client"
43
+ MODULE_IDENTITY_API_CLIENT_SECRET: "sample-app-secret"
44
+ ```
45
+
46
+ Now all the environment variables will be accessible like ENV["MODULE_IDENTITY_API_HOST_URL"] in our Rails application.
47
+
48
+
49
+ 2. After that create an application context ruby file under /config/intializers as follows:
50
+ ```ruby
51
+ class IdsRailsApiContext < IdnSdkRuby::Com::Nbos::Capi::Api::V0::InMemoryApiContext
52
+
53
+ def initialize(name = nil, conText = nil)
54
+ super(name) if name != nil
55
+ end
56
+
57
+ def init()
58
+ end
59
+
60
+ #CLIENT TOKEN set/get
61
+ def setClientToken(tokenApiModel)
62
+ super(tokenApiModel)
63
+ end
64
+
65
+ def getClientToken
66
+ tokenApiModel = super
67
+ if (tokenApiModel != nil)
68
+ return tokenApiModel
69
+ else
70
+ return nil
71
+ end
72
+ end
73
+
74
+ def setUserToken(moduleName, tokenApiModel)
75
+ super(moduleName, tokenApiModel)
76
+ end
77
+
78
+ def getUserToken(moduleName)
79
+ tokenApiModel = super(moduleName)
80
+ if (tokenApiModel != nil)
81
+ return tokenApiModel
82
+ else
83
+ return nil
84
+ end
85
+ end
86
+
87
+ def getHost(moduleName)
88
+ host = super(moduleName)
89
+ if host != nil
90
+ return host
91
+ else
92
+ return "http://api.qa1.nbos.in"
93
+ end
94
+ end
95
+
96
+ def setHost(moduleName)
97
+ #Read host name from ENVS
98
+ host = ENV["MODULE_#{moduleName.upcase}_API_HOST_URL"]
99
+ if moduleName != nil && host != nil
100
+ super(moduleName, host)
101
+ else
102
+ super(moduleName, "http://api.qa1.nbos.in")
103
+ end
104
+
105
+ end
106
+
107
+ def setClientCredentials(moduleName)
108
+ map = {}
109
+ #Read client credentials from ENVS
110
+ client_key = ENV["MODULE_#{moduleName.upcase}_API_CLIENT_KEY"]
111
+ client_secret = ENV["MODULE_#{moduleName.upcase}_API_CLIENT_SECRET"]
112
+ map["client_id"] = client_key != nil ? client_key :"sample-app-client"
113
+ map["client_secret"] = client_secret != nil ? client_secret :"sample-app-secret"
114
+ super(map)
115
+ end
116
+ end
117
+
118
+ app_context = IdsRailsApiContext.new("app")
119
+ app_context.setHost("identity")
120
+ app_context.setClientCredentials("identity")
121
+ IdnSdkRuby::Com::Nbos::Capi::Api::V0::IdnSDK.init(app_context)
122
+ ```
123
+
124
+ 2. Now we are ready to communicate with IDN registered modules identity & media.
125
+
126
+ ```ruby
127
+ # To get identity module api instance
128
+ identity_api = IdnSdkRuby::Com::Nbos::Capi::Modules::Ids::V0::Ids.getModuleApi("identity")
129
+ loginModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::LoginModel.new(name, code)
130
+ member_model = identity_api.login(loginModel)
131
+
132
+ # To get Media module api instance
133
+ media_api = IdnSdkRuby::Com::Nbos::Capi::Modules::Ids::V0::Ids.getModuleApi("media")
134
+ media_model = media_api.getMedia(member_model.uuid, "profile")
135
+ ```
136
+
26
137
 
27
138
  ## Development
28
139
 
@@ -32,7 +143,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
143
 
33
144
  ## Contributing
34
145
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/idn_sdk_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
146
+ Bug reports and pull requests are welcome on GitHub at https://gitlab.com/[USERNAME]/idn_sdk_ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
36
147
 
37
148
 
38
149
  ## License
data/lib/idn_sdk_ruby.rb CHANGED
@@ -8,6 +8,8 @@ require "idn_sdk_ruby/com/nbos/capi/api/v0/network_callback"
8
8
  require "idn_sdk_ruby/com/nbos/capi/api/v0/token_api_model"
9
9
  require "idn_sdk_ruby/com/nbos/capi/api/v0/idn_sdk"
10
10
 
11
+ require "idn_sdk_ruby/com/nbos/capi/modules/core/v0/module_api_model"
12
+
11
13
  require "idn_sdk_ruby/com/nbos/capi/modules/ids/v0/ids"
12
14
  require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_ids_registry"
13
15
  require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/identity_remote_api"
@@ -20,6 +22,7 @@ require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/new_member_api_model"
20
22
  require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_signup_model"
21
23
  require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/update_password_api_model"
22
24
  require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/basic_active_model"
25
+ require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model"
23
26
 
24
27
  require "idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_ids_registry"
25
28
  require "idn_sdk_ruby/com/nbos/capi/modules/media/v0/media_remote_api"
@@ -32,7 +32,7 @@ module IdnSdkRuby
32
32
  def getClientCredentials
33
33
  end
34
34
 
35
- def getClientToken
35
+ def getClientToken(scope = nil)
36
36
  end
37
37
 
38
38
  def setUserToken(moduleName, tokenApiModel)
@@ -1,26 +1,26 @@
1
1
 
2
2
  class IdnSdkRuby::Com::Nbos::Capi::Api::V0::IdnSDK
3
3
 
4
- def self.init(apiContext)
4
+ def self.init(apiContext, scope = nil)
5
5
  IdnSdkRuby::Com::Nbos::Capi::Api::V0::AbstractApiContext.registerApiContext(apiContext)
6
6
  if apiContext != nil
7
7
  apiContext.init
8
8
  puts "From IDN SDK Init => #{apiContext}"
9
9
  end
10
10
 
11
+ # Register Default modules identity & media
11
12
  begin
12
- IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::IdentityIdsRegistry.new
13
- IdnSdkRuby::Com::Nbos::Capi::Modules::Media::V0::MediaIdsRegistry.new
13
+ IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::IdentityIdsRegistry.init
14
+ IdnSdkRuby::Com::Nbos::Capi::Modules::Media::V0::MediaIdsRegistry.init
14
15
  rescue Exception => e
15
16
  puts "#{e.message}"
16
17
  puts "#{e.backtrace}"
17
18
  end
18
-
19
- tokenApiModel = apiContext.getClientToken
20
- if tokenApiModel == nil
19
+ #tokenApiModel = apiContext.getClientToken(scope)
20
+ #if tokenApiModel == nil
21
21
  identityApi = IdnSdkRuby::Com::Nbos::Capi::Modules::Ids::V0::Ids.getModuleApi("identity", apiContext.name)
22
- identityApi.getClientToken
23
- end
22
+ tokenApiModel = identityApi.getClientToken(scope)
23
+ #end
24
24
  end
25
25
 
26
26
  end
@@ -25,7 +25,7 @@ class IdnSdkRuby::Com::Nbos::Capi::Api::V0::InMemoryApiContext < IdnSdkRuby::Com
25
25
  @@store["token.client"]=tokenApiModel
26
26
  end
27
27
 
28
- def getClientToken()
28
+ def getClientToken(scope = nil)
29
29
  return @@store["token.client"]
30
30
  end
31
31
 
@@ -1,7 +1,7 @@
1
- require 'json'
1
+ require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/basic_active_model"
2
2
 
3
- class IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel
4
- attr_accessor :scope, :expires_in, :token_type, :refresh_token, :access_token
3
+ class IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel < IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::BasicActiveModel
4
+ attr_accessor :scope, :expires_in, :token_type, :refresh_token, :access_token, :message
5
5
 
6
6
  def initialize(parsed_response = nil)
7
7
  if !parsed_response.nil?
@@ -33,6 +33,23 @@ class IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel
33
33
  return @access_token
34
34
  end
35
35
 
36
+ def add_errors(json_response)
37
+ json_response["errors"].each do |e|
38
+ property_name = e['propertyName']
39
+ msg = e['message']
40
+ self.errors[property_name] << msg
41
+ end
42
+ end
43
+
44
+ def add_messages(json_response)
45
+ if json_response["message"].present?
46
+ @message = json_response["message"]
47
+ elsif json_response["error"].present?
48
+ @message = json_response["error"]
49
+ end
50
+
51
+ end
52
+
36
53
  def as_json(options={})
37
54
  {
38
55
  scope: @scope,
@@ -1,3 +1,4 @@
1
+ require "idn_sdk_ruby/com/nbos/capi/modules/identity/v0/basic_active_model"
1
2
  module IdnSdkRuby
2
3
  module Com
3
4
  module Nbos
@@ -5,8 +6,13 @@ module IdnSdkRuby
5
6
  module Modules
6
7
  module Core
7
8
  module V0
8
- class ModuleApiModel
9
- attr_accessor :uuid, :name
9
+ class ModuleApiModel < IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::BasicActiveModel
10
+ attr_accessor :uuid, :name, :message
11
+
12
+ def initialize(uuid = nil, name = nil)
13
+ @uuid = uuid
14
+ @name = name
15
+ end
10
16
 
11
17
  def getUuid()
12
18
  return @uuid
@@ -15,9 +21,40 @@ module IdnSdkRuby
15
21
  def getName()
16
22
  return @name
17
23
  end
24
+
25
+ def as_json(options={})
26
+ {
27
+ uuid: @uuid,
28
+ name: @name
29
+ }
30
+ end
31
+
32
+ def to_json(*options)
33
+ as_json(*options).to_json(*options)
34
+ end
35
+
36
+ def to_s
37
+ to_json
38
+ end
39
+
40
+ def add_errors(json_response)
41
+ json_response["errors"].each do |e|
42
+ property_name = e['propertyName']
43
+ msg = e['message']
44
+ self.errors[property_name] << msg
45
+ end
46
+ end
47
+
48
+ def add_messages(json_response)
49
+ if json_response["message"].present?
50
+ @message = json_response["message"]
51
+ elsif json_response["error"].present?
52
+ @message = json_response["error"]
53
+ end
54
+
55
+ end
18
56
 
19
57
  end
20
- end
21
58
  end
22
59
  end
23
60
  end
@@ -15,12 +15,12 @@ module IdnSdkRuby
15
15
  @remoteApiObj = getRemoteApiClass().new
16
16
  end
17
17
 
18
- def getClientToken()
18
+ def getClientToken(scope = nil)
19
19
  remoteApi = @remoteApiObj
20
20
  map = @apiContext.getClientCredentials()
21
21
  clientId = map["client_id"]
22
22
  secret = map["client_secret"]
23
- response = remoteApi.getToken(clientId, secret, "client_credentials")
23
+ response = remoteApi.getToken(clientId, secret, "client_credentials", scope)
24
24
  if response.code == 200
25
25
  tokenApiModel = IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel.new(response.parsed_response)
26
26
  @apiContext.setClientToken(tokenApiModel)
@@ -37,13 +37,13 @@ module IdnSdkRuby
37
37
  if response.code == 200
38
38
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response)
39
39
  @apiContext.setUserToken('identity', memberApiModel.token.getAccess_token)
40
- { status: 200, member: memberApiModel}
40
+ { status: 200, data: memberApiModel}
41
41
  elsif response.code == 400
42
42
  loginModel.add_errors(response.parsed_response)
43
- { status: 400, member: nil, login: loginModel}
43
+ { status: 400, data: loginModel}
44
44
  else
45
45
  loginModel.add_messages(response.parsed_response)
46
- { status: response.code, login: loginModel}
46
+ { status: response.code, data: loginModel}
47
47
  end
48
48
  end
49
49
 
@@ -55,15 +55,15 @@ module IdnSdkRuby
55
55
  if response.code == 200
56
56
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response)
57
57
  @apiContext.setUserToken('identity', memberApiModel.token.getAccess_token)
58
- {status: 200, member: memberApiModel}
58
+ {status: 200, data: memberApiModel}
59
59
  elsif response.code == 400
60
60
  memberSignupModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberSignupModel.new
61
61
  memberSignupModel.add_errors(response.parsed_response)
62
- {status: response.code, member: memberSignupModel}
62
+ {status: response.code, data: memberSignupModel}
63
63
  else
64
64
  memberSignupModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberSignupModel.new
65
65
  memberSignupModel.add_messages(response.parsed_response)
66
- {status: response.code, member: memberApiModel}
66
+ {status: response.code, data: memberApiModel}
67
67
  end
68
68
  end
69
69
 
@@ -77,15 +77,15 @@ module IdnSdkRuby
77
77
  if response.code == 200
78
78
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response)
79
79
  @apiContext.setUserToken('identity', memberApiModel.token.getAccess_token)
80
- { status: 200, login: memberApiModel}
80
+ { status: 200, data: memberApiModel}
81
81
  elsif response.code == 400
82
82
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new
83
83
  memberApiModel.add_errors(response.parsed_response)
84
- { status: 400, login: memberApiModel}
84
+ { status: 400, data: memberApiModel}
85
85
  else
86
86
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new
87
87
  memberApiModel.add_messages(response.parsed_response)
88
- { status: response.code, login: memberApiModel}
88
+ { status: response.code, data: memberApiModel}
89
89
  end
90
90
  end
91
91
 
@@ -99,11 +99,11 @@ module IdnSdkRuby
99
99
 
100
100
  if response.code == 200
101
101
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response, false)
102
- {status: 200, member: memberApiModel}
102
+ {status: 200, data: memberApiModel}
103
103
  else
104
104
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(nil, false)
105
105
  memberApiModel.add_messages(response.parsed_response)
106
- { status: response.code, member: memberApiModel}
106
+ { status: response.code, data: memberApiModel}
107
107
  end
108
108
  end
109
109
 
@@ -114,10 +114,10 @@ module IdnSdkRuby
114
114
 
115
115
  if response.code == 200
116
116
  memberApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::MemberApiModel.new(response.parsed_response, false)
117
- {status: 200, member: memberApiModel}
117
+ {status: 200, data: memberApiModel}
118
118
  elsif response.code == 400
119
119
  memberApiModel.add_errors(api_response.parsed_response)
120
- {status: 400, member: memberApiModel}
120
+ {status: 400, data: memberApiModel}
121
121
  end
122
122
  end
123
123
 
@@ -128,10 +128,10 @@ module IdnSdkRuby
128
128
 
129
129
  if response.code == 400
130
130
  updatePasswordApiModel.add_errors(response.parsed_response)
131
- { status: 400, login: updatePasswordApiModel}
131
+ { status: 400, data: updatePasswordApiModel}
132
132
  else
133
133
  updatePasswordApiModel.add_messages(response.parsed_response)
134
- { status: response.code, login: updatePasswordApiModel}
134
+ { status: response.code, data: updatePasswordApiModel}
135
135
  end
136
136
  end
137
137
 
@@ -147,10 +147,10 @@ module IdnSdkRuby
147
147
  if response.code == 200
148
148
  @apiContext.setUserToken('identity', nil)
149
149
  loginModel.add_messages(response.parsed_response)
150
- {status: 200, login: loginModel}
150
+ {status: 200, data: loginModel}
151
151
  else
152
152
  loginModel.add_messages(response.parsed_response)
153
- {status: response.code, login: loginModel}
153
+ {status: response.code, data: loginModel}
154
154
  end
155
155
  end
156
156
 
@@ -158,6 +158,19 @@ module IdnSdkRuby
158
158
 
159
159
  end
160
160
 
161
+ def tokenVerify(authorization, tokenToVerify, module_key)
162
+ remoteApi = @remoteApiObj
163
+ response = remoteApi.tokenVerify(authorization, tokenToVerify, module_key)
164
+ if response.code == 200
165
+ moduleTokenApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::ModuleTokenApiModel.new(response.parsed_response)
166
+ {status: 200, data: moduleTokenApiModel}
167
+ else
168
+ moduleTokenApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::ModuleTokenApiModel.new
169
+ moduleTokenApiModel.add_messages(response.parsed_response)
170
+ {status: response.code, data: moduleTokenApiModel}
171
+ end
172
+ end
173
+
161
174
  end
162
175
  end
163
176
  end
@@ -8,7 +8,7 @@ module IdnSdkRuby
8
8
  module Identity
9
9
  module V0
10
10
  class IdentityIdsRegistry
11
- def initialize()
11
+ def self.init
12
12
  IdnSdkRuby::Com::Nbos::Capi::Modules::Ids::V0::Ids.register("identity", IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::IdentityApi)
13
13
  end
14
14
  end
@@ -30,6 +30,7 @@ module IdnSdkRuby
30
30
  def initialize()
31
31
  @baseIdentityUrl = "/api/identity/v0"
32
32
  @tokenUrl = "/oauth/token"
33
+ @tokenVerifyUrl = "/api/oauth/v0/tokens"
33
34
  @loginUrl = @baseIdentityUrl + "/auth/login"
34
35
  @signupUrl = @baseIdentityUrl + "/users/signup"
35
36
  @profileUrl = @baseIdentityUrl + "/users"
@@ -41,8 +42,9 @@ module IdnSdkRuby
41
42
  @socialLoginUrl = @baseIdentityUrl + "/auth/social/{loginService}/login"
42
43
  end
43
44
 
44
- def getToken(clientId, clientSecret, grantType)
45
- query_params = {:client_id => clientId, :client_secret => clientSecret, :grant_type => grantType}
45
+ def getToken(clientId, clientSecret, grantType, scope = nil)
46
+ scope = scope.nil? ? [] : scope
47
+ query_params = {:client_id => clientId, :client_secret => clientSecret, :grant_type => grantType, :scope => scope}
46
48
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
47
49
  response = self.class.send("get", @host_url+@tokenUrl, :query => query_params)
48
50
  return response
@@ -54,7 +56,6 @@ module IdnSdkRuby
54
56
  def login(authorization, loginModel)
55
57
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
56
58
  body = loginModel.to_s
57
- #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
58
59
  response = self.class.send("post", @host_url+@loginUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
59
60
  return response
60
61
  end
@@ -62,7 +63,6 @@ module IdnSdkRuby
62
63
  def signup(authorization, memberSignupModel)
63
64
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
64
65
  body = memberSignupModel.to_s
65
- #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
66
66
  response = self.class.send("post", @host_url+@signupUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
67
67
  return response
68
68
  end
@@ -72,7 +72,6 @@ module IdnSdkRuby
72
72
 
73
73
  def updateCredentials(authorization,updatePasswordApiModel)
74
74
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
75
- #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
76
75
  body = updatePasswordApiModel.to_s
77
76
  response = self.class.send("post", @host_url+@changeUrl, :body => body, :headers => {"Authorization" => "Bearer " + authorization})
78
77
  return response
@@ -88,8 +87,8 @@ module IdnSdkRuby
88
87
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
89
88
  @connect_service = get_social_login_uri(connectService)
90
89
  body = { :clientId => clientId,
91
- :accessToken => oauth_details[:credentials][:token],
92
- :expiresIn => "#{oauth_details[:credentials][:expires_at]}"
90
+ :accessToken => oauth_details[:credentials][:token],
91
+ :expiresIn => "#{oauth_details[:credentials][:expires_at]}"
93
92
  }
94
93
  response = self.class.send("post", @host_url+@connect_service, :body => body.to_json, :headers => {"Authorization" => "Bearer " + authorization})
95
94
  return response
@@ -103,14 +102,12 @@ module IdnSdkRuby
103
102
 
104
103
  def getMemberDetails(authorization, uuid)
105
104
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
106
- #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
107
105
  response = self.class.send("get", @host_url+@profileUrl+"/#{uuid}", :headers => {"Authorization" => "Bearer " + authorization})
108
106
  return response
109
107
  end
110
108
 
111
109
  def updateMemberDetails(authorization, uuid, memberApiModel)
112
110
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
113
- #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
114
111
  body = memberApiModel.to_s
115
112
  response = self.class.send("put", @host_url+@profileUrl+"/#{uuid}", :body => body, :headers => {"Authorization" => "Bearer " + authorization})
116
113
  return response
@@ -135,6 +132,12 @@ module IdnSdkRuby
135
132
  INVALID_SOCIAL_URI
136
133
  end
137
134
  end
135
+
136
+ def tokenVerify(authorization, tokenToVerify, module_key)
137
+ @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
138
+ response = self.class.send("get", @host_url+@tokenVerifyUrl+"/#{tokenToVerify}", :headers => {"Authorization" => "Bearer " + authorization, "x-module-key" => module_key})
139
+ return response
140
+ end
138
141
 
139
142
  end
140
143
  end
@@ -22,7 +22,6 @@ module IdnSdkRuby
22
22
  @phone = member_details["phone"]
23
23
  add_socialAccounts(member_details["socialAccounts"])
24
24
  add_emailConnects(member_details["emailConnects"])
25
- token_details = parsed_response["token"].nil? ? nil : parsed_response["token"]
26
25
  @token = IdnSdkRuby::Com::Nbos::Capi::Api::V0::TokenApiModel.new(parsed_response["token"])
27
26
  end
28
27
  end
@@ -0,0 +1,78 @@
1
+ module IdnSdkRuby
2
+ module Com
3
+ module Nbos
4
+ module Capi
5
+ module Modules
6
+ module Identity
7
+ module V0
8
+ class ModuleTokenApiModel < IdnSdkRuby::Com::Nbos::Capi::Modules::Identity::V0::BasicActiveModel
9
+ attr_accessor :username, :clientId, :tokenType, :token, :expiration, :expired, :tenantId, :modules, :message
10
+
11
+ def initialize(parsed_response = nil)
12
+ if !parsed_response.nil?
13
+ @username = parsed_response['username']
14
+ @clientId = parsed_response['clientId']
15
+ @tokenType = parsed_response['tokenType']
16
+ @token = parsed_response['token']
17
+ @expiration = parsed_response['expiration']
18
+ @expired = parsed_response['expired']
19
+ @tenantId = parsed_response['tenantId']
20
+ @modules = add_modules(parsed_response['modules']) if parsed_response['modules'].present?
21
+ end
22
+ end
23
+
24
+ def add_modules(modules)
25
+ @modules = []
26
+ if modules.size > 0
27
+ modules.each do |m|
28
+ @modules << IdnSdkRuby::Com::Nbos::Capi::Modules::Core::V0::ModuleTokenApiModel.new(m)
29
+ end
30
+ end
31
+ end
32
+
33
+
34
+ def add_errors(json_response)
35
+ json_response["errors"].each do |e|
36
+ property_name = e['propertyName']
37
+ msg = e['message']
38
+ self.errors[property_name] << msg
39
+ end
40
+ end
41
+
42
+ def add_messages(json_response)
43
+ if json_response["message"].present?
44
+ @message = json_response["message"]
45
+ elsif json_response["error"].present?
46
+ @message = json_response["error"]
47
+ end
48
+
49
+ end
50
+
51
+ def as_json(options={})
52
+ {
53
+ username: @username,
54
+ clientId: @clientId,
55
+ tokenType: @tokenType,
56
+ token: @token,
57
+ expiration: @expiration,
58
+ expired: @expired,
59
+ tenantId: @tenantId,
60
+ modules: @modules
61
+ }
62
+ end
63
+
64
+ def to_json(*options)
65
+ as_json(*options).to_json(*options)
66
+ end
67
+
68
+ def to_s
69
+ to_json
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -22,11 +22,11 @@ module IdnSdkRuby
22
22
  if response.code == 200
23
23
  if !response["extension"].nil?
24
24
  mediaApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Media::V0::MediaApiModel.new(response.parsed_response)
25
- return {:status => 200, :media => mediaApiModel}
25
+ return {status: 200, data: mediaApiModel}
26
26
  else
27
27
  mediaApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Media::V0::MediaApiModel.new
28
28
  mediaApiModel.add_message(response.parsed_response)
29
- return {:status => 200, :media => mediaApiModel}
29
+ return {status: 200, data: mediaApiModel}
30
30
  end
31
31
  else
32
32
  return response.parsed_response
@@ -41,11 +41,11 @@ module IdnSdkRuby
41
41
  if response.code == 200
42
42
  if !response["extension"].nil?
43
43
  mediaApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Media::V0::MediaApiModel.new(response.parsed_response)
44
- return {:status => 200, :media => mediaApiModel}
44
+ return {status: 200, data: mediaApiModel}
45
45
  else
46
46
  mediaApiModel = IdnSdkRuby::Com::Nbos::Capi::Modules::Media::V0::MediaApiModel.new
47
47
  mediaApiModel.message(response.parsed_response)
48
- return {:status => 200, :media => mediaApiModel}
48
+ return {status: 200, data: mediaApiModel}
49
49
  end
50
50
  else
51
51
  return response.parsed_response
@@ -7,7 +7,7 @@ module IdnSdkRuby
7
7
  module V0
8
8
  class MediaIdsRegistry
9
9
 
10
- def initialize
10
+ def self.init
11
11
  IdnSdkRuby::Com::Nbos::Capi::Modules::Ids::V0::Ids.register("media", IdnSdkRuby::Com::Nbos::Capi::Modules::Media::V0::MediaApi)
12
12
  end
13
13
  end
@@ -22,7 +22,6 @@ module IdnSdkRuby
22
22
 
23
23
  def getMedia(authorization, uuid, mediafor)
24
24
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
25
- #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
26
25
  query_params = { :id => uuid, :mediafor => mediafor}
27
26
  response = self.class.send("get", @host_url+@mediaUrl, :query => query_params, :headers => {"Authorization" => "Bearer " + authorization})
28
27
  return response
@@ -30,7 +29,6 @@ module IdnSdkRuby
30
29
 
31
30
  def uploadMedia(authorization, uuid, mediafor, media_file)
32
31
  @host_url = "http://api.qa1.nbos.in" if @host_url.nil?
33
- #response= HTTParty.post(@host_url+@loginUrl,{:body => body, :headers => { "Authorization" => "Bearer #{authorization}"}})
34
32
  query_params = { :id => uuid, :mediafor => mediafor}
35
33
  body = {:file => media_file}
36
34
  response = self.class.send("post", @host_url+@mediaUrl, :body => body, :query => query_params, :headers => {"Authorization" => "Bearer " + authorization})
@@ -1,3 +1,3 @@
1
1
  module IdnSdkRuby
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: idn_sdk_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - sekhar
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-25 00:00:00.000000000 Z
11
+ date: 2016-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httmultiparty
@@ -156,6 +156,7 @@ files:
156
156
  - lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/login_model.rb
157
157
  - lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_api_model.rb
158
158
  - lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/member_signup_model.rb
159
+ - lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/module_token_api_model.rb
159
160
  - lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/new_member_api_model.rb
160
161
  - lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/reset_password_model.rb
161
162
  - lib/idn_sdk_ruby/com/nbos/capi/modules/identity/v0/social_account_api_model.rb