wavelabs_client_api 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.travis.yml +8 -0
  4. data/CODE_OF_CONDUCT.md +13 -0
  5. data/Gemfile +6 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +140 -0
  8. data/Rakefile +12 -0
  9. data/bin/console +14 -0
  10. data/bin/setup +7 -0
  11. data/lib/generators/templates/wavelabs_client_api_initializer.rb +13 -0
  12. data/lib/generators/wavelabs_client_api/install_generator.rb +17 -0
  13. data/lib/wavelabs_client_api.rb +34 -0
  14. data/lib/wavelabs_client_api/client/api/core/auth_api.rb +179 -0
  15. data/lib/wavelabs_client_api/client/api/core/base_api.rb +92 -0
  16. data/lib/wavelabs_client_api/client/api/core/media_api.rb +48 -0
  17. data/lib/wavelabs_client_api/client/api/core/social_api.rb +78 -0
  18. data/lib/wavelabs_client_api/client/api/core/users_api.rb +90 -0
  19. data/lib/wavelabs_client_api/client/api/data_models/base_api_model.rb +40 -0
  20. data/lib/wavelabs_client_api/client/api/data_models/login_api_model.rb +41 -0
  21. data/lib/wavelabs_client_api/client/api/data_models/media_api_model.rb +26 -0
  22. data/lib/wavelabs_client_api/client/api/data_models/member_api_model.rb +55 -0
  23. data/lib/wavelabs_client_api/client/api/data_models/message_api_model.rb +19 -0
  24. data/lib/wavelabs_client_api/client/api/data_models/social_accounts_api_model.rb +41 -0
  25. data/lib/wavelabs_client_api/client/api/data_models/token_api_model.rb +37 -0
  26. data/lib/wavelabs_client_api/client/api/data_models/token_details_api_model.rb +51 -0
  27. data/lib/wavelabs_client_api/version.rb +3 -0
  28. data/spec/core_api_specs/auth_api_spec.rb +90 -0
  29. data/spec/core_api_specs/media_api_spec.rb +38 -0
  30. data/spec/core_api_specs/social_api_spec.rb +32 -0
  31. data/spec/core_api_specs/users_api_spec.rb +65 -0
  32. data/spec/data_model_specs/login_api_model_spec.rb +27 -0
  33. data/spec/data_model_specs/media_api_model_spec.rb +21 -0
  34. data/spec/data_model_specs/member_api_model_spec.rb +38 -0
  35. data/spec/data_model_specs/message_api_model_spec.rb +19 -0
  36. data/spec/data_model_specs/social_accounts_api_model_spec.rb +25 -0
  37. data/spec/data_model_specs/token_api_model_spec.rb +21 -0
  38. data/spec/spec_helper.rb +28 -0
  39. data/spec/support/temp_user.doc +0 -0
  40. data/spec/support/temp_user.png +0 -0
  41. data/spec/support/user_sign_up.rb +20 -0
  42. data/wavelabs_client_api.gemspec +41 -0
  43. metadata +183 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad248de74514dbe4c337a35159b3c4a2ec5093de
4
+ data.tar.gz: db071cb2e5a64da44d2a3695d0871f8f72b1b8fe
5
+ SHA512:
6
+ metadata.gz: afb8012f604966605637014020e22c23958c6907f65bf8aa8d64d391f646a1f38c59ac2c07e9baefe7f005bb28a24aaf554d3f5a565a3a0cc5ddc0de766cfbb2
7
+ data.tar.gz: 53aa1f7008c2cad041c44475c70337a30533a513e0aba47c8ba274b1e727ebb237fd24c9b3721267946edbeb661037beefa98b01449dc3eaffe4d23ea51057b0
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ .byebug_history
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
5
+
6
+ addons:
7
+ code_climate:
8
+ repo_token: 1d83847d90af4ec2619c0adff9b60265cd770a7f7b6317026ff0cee3a59b630a
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in wavelabs_client_api.gemspec
4
+ gemspec
5
+
6
+ gem "codeclimate-test-reporter", group: :test, require: nil
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 sekhar
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,140 @@
1
+
2
+ # Current Version
3
+ [![Gem Version](https://badge.fury.io/rb/wavelabs_client_api.svg)](https://badge.fury.io/rb/wavelabs_client_api)
4
+
5
+ # Code Statistics
6
+ [![Build Status](https://travis-ci.org/nbostech/wavelabs-client-api.svg?branch=master)](https://travis-ci.org/nbostech/wavelabs-client-api)
7
+ [![Code Climate](https://codeclimate.com/github/nbostech/wavelabs-client-api/badges/gpa.svg)](https://codeclimate.com/github/nbostech/wavelabs-client-api)
8
+ [![Test Coverage](https://codeclimate.com/github/nbostech/wavelabs-client-api/badges/coverage.svg)](https://codeclimate.com/github/nbostech/wavelabs-client-api/coverage)
9
+
10
+
11
+
12
+ # WavelabsClientApi
13
+
14
+ Welcome to "wavelabs_client_api" gem. It is flexible wrapper to communicate with Wavelabs Server API. Using this library you can easily interact with Wavelabs Server API. This release supports User Registration Module:
15
+
16
+ 1. Sign Up
17
+ 2. Sign In
18
+ 3. Forgot Password
19
+ 4. Change Password
20
+ 5. Edit Profile
21
+ 6. Upload Profile Picture
22
+ 7. Social Sign Up(Login with facebook, github ..etc)
23
+
24
+ This library is used to send requests to Wavelabs Server API and get response. Following are the run time dependencies
25
+
26
+ 1. ruby-2.2.3
27
+ 2. activemodel-4.2.4
28
+ 3. httmultiparty-0.3.16
29
+
30
+ There is an example rails application in github https://github.com/nbostech/wavelabs-rails-client-api. You can clone and use that application.
31
+
32
+ Live example is available on heroku https://wavelabs-rails-client-api.herokuapp.com
33
+
34
+ This gem contains two main modules under /lib directory
35
+
36
+ 1. WaveLabsClientApi::Client::Api::Core which have the classes to handle server communication.
37
+
38
+ 2. WaveLabsClientApi::Client::Api::DataModels which have the ActiveModel classes to create model objects.
39
+
40
+
41
+ ## Installation
42
+
43
+ Add this line to your application's Gemfile:
44
+
45
+ ```ruby
46
+ gem 'wavelabs_client_api'
47
+ ```
48
+
49
+ And then execute:
50
+
51
+ $ bundle
52
+
53
+ Or install it yourself as:
54
+
55
+ $ gem install wavelabs_client_api
56
+
57
+ After successful instalation run the following command to generate wavelabs_client_api.rb configuration file under config/initializers directory
58
+
59
+ $ rails g wavelabs_client_api:install
60
+
61
+ In above configuration file setup the following core variables to work with API Server.
62
+
63
+ 1. If you want to use ENV variables jump to Usage section. Nothing to change in configuration file.
64
+
65
+ 2. If you are not using ENV variables provide configuration option values in wavelabs_client_api.rb file in initializers directory as follows:
66
+ ```
67
+
68
+ WavelabsClientApi.configure do |config|
69
+ config.api_host_url = "your API server url"
70
+ config.client_key = "your client key"
71
+ config.client_secret = "your client secret"
72
+ end
73
+ ```
74
+
75
+
76
+ ## Usage
77
+
78
+ After installing the gem & configuration file you can create your own controllers & use the Core module class methods to comminicate Wavelabs Server API. To use this wrapper first you need to add following environment(ENV) variables in your rails aplication:
79
+ ```
80
+
81
+ ### WaveLabs Server Details
82
+ ENV['API_HOST_URL'] = 'http://api.qa1.wavelabs.in/'
83
+ ENV['API_CLIENT_KEY'] = 'my-client'
84
+ ENV['API_CLIENT_SECRET'] = 'my-secret'
85
+
86
+ ### Social Login Details
87
+ ENV['FACEBOOK_KEY'] = 'FACEBOOK APP KEY'
88
+ ENV['FACEBOOK_SECRET'] = 'FACEBOOK APP SECRET'
89
+
90
+ ENV['GOOGLE_KEY'] = 'GOOGLE APP KEY'
91
+ ENV['GOOGLE_SECRET'] = 'GOOGLE APP SECRET'
92
+
93
+ ENV['GITHUB_KEY'] = 'GITHUB APP KEY'
94
+ ENV['GITHUB_SECRET'] = 'GITHUB APP SECRET'
95
+
96
+ ENV['LINKEDIN_KEY'] = 'LINKEDIN APP KEY'
97
+ ENV['LINKEDIN_SECRET'] = "LINKEDIN APP SECRET"
98
+
99
+ ENV['INSTAGRAM_KEY'] = 'INSTAGRAM APP KEY'
100
+ ENV['INSTAGRAM_SECRET'] = 'INSTAGRAM APP KEY'
101
+ ```
102
+
103
+ There are many ways to setup the ENV variables in rails. You can directly add them into your environment specific rb file, for example 'config/enviroments/development.rb' or you can use 'dot-env'/'figaro' gems.
104
+
105
+ Note: You can use above Wavelabs Server details. It's public. And you need to create your own apps for social logins & modify social login details.
106
+
107
+ Now you are ready to communicate with the Server. Following is an example to send a sign_up request from ruby console:
108
+
109
+ $auth_api = WavelabsClientApi::Client::Api::Core::AuthApi.new
110
+ $get_token_req = auth_api.get_auth_token("client_credentials", "oauth.client.r")
111
+ $request = WavelabsClientApi::Client::Api::Core::UsersApi.new
112
+ $sign_up_params = { :username => "username",
113
+ :password => "password123",
114
+ :email => "username@test.com",
115
+ :firstName => "first name",
116
+ :lastName => "last name"
117
+ }
118
+ $response = request.sign_up(sign_up_params, get_token_req[:token].value)
119
+
120
+ You will get the approprivate response from server. If you want to use this gem in your rails application I have created a sample application here https://github.com/nbostech/wavelabs-rails-client-api
121
+
122
+ ## Note
123
+ continuous changes will be made based on Wavelabs Server API architecture.
124
+
125
+
126
+ ## Development
127
+
128
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
129
+
130
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
131
+
132
+ ## Contributing
133
+
134
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/wavelabs_client_api. 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.
135
+
136
+
137
+ ## License
138
+
139
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
140
+
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+
7
+ # If you want to make this the default task
8
+ task :default => :spec
9
+
10
+ RSpec::Core::RakeTask.new do |task|
11
+ task.rspec_opts = ['--color', '--format', 'doc']
12
+ end
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wavelabs_client_api"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,13 @@
1
+ WavelabsClientApi.configure do |config|
2
+ # Set this options to what makes sense for you
3
+ # If you are using ENV variables setup the required ENV variables
4
+ config.api_host_url = ENV['API_HOST_URL']
5
+ config.client_key = ENV['API_CLIENT_KEY']
6
+ config.client_secret = ENV['API_CLIENT_SECRET']
7
+
8
+ # If you are not using ENV variables comment out the follwing lines
9
+ # And provide your api server url, client key & client secret
10
+ # config.api_host_url = "API Server Url"
11
+ # config.client_key = "Client Key"
12
+ # config.client_secret = "Client Secret"
13
+ end
@@ -0,0 +1,17 @@
1
+ module WavelabsClientApi
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+ desc "Creates wavelabs client api initializer for your application"
6
+
7
+ def copy_initializer
8
+ template "wavelabs_client_api_initializer.rb", "config/initializers/wavelabs_client_api.rb"
9
+
10
+ puts "Install complete! Please make sure to set following ENV variables!"
11
+ puts "ENV['API_HOST_URL'] = 'site url' "
12
+ puts "ENV['CLIENT_ID'] = 'XXXXXX'"
13
+ puts "ENV['CLIENT_SECRET'] = 'XXXXXXXXX' "
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,34 @@
1
+ require "wavelabs_client_api/version"
2
+
3
+ require "wavelabs_client_api/client/api/core/base_api"
4
+ require "wavelabs_client_api/client/api/core/auth_api"
5
+ require "wavelabs_client_api/client/api/core/users_api"
6
+ require "wavelabs_client_api/client/api/core/media_api"
7
+ require "wavelabs_client_api/client/api/core/social_api"
8
+
9
+
10
+ require "wavelabs_client_api/client/api/data_models/base_api_model"
11
+ require "wavelabs_client_api/client/api/data_models/login_api_model"
12
+ require "wavelabs_client_api/client/api/data_models/media_api_model"
13
+ require "wavelabs_client_api/client/api/data_models/member_api_model"
14
+ require "wavelabs_client_api/client/api/data_models/message_api_model"
15
+ require "wavelabs_client_api/client/api/data_models/social_accounts_api_model"
16
+ require "wavelabs_client_api/client/api/data_models/token_api_model"
17
+ require "wavelabs_client_api/client/api/data_models/token_details_api_model"
18
+
19
+ module WavelabsClientApi
20
+
21
+ class << self
22
+ attr_accessor :configuration
23
+ end
24
+
25
+ def self.configure
26
+ self.configuration ||= Configuration.new
27
+ yield(configuration)
28
+ end
29
+
30
+ class Configuration
31
+ attr_accessor :api_host_url, :client_key, :client_secret
32
+ end
33
+
34
+ end
@@ -0,0 +1,179 @@
1
+
2
+ # This class is responsible for handling
3
+ # Requests from Com::Nbos::Core::AuthController.
4
+ # It will create the request based on Controller request params and
5
+ # send that request to Wavelabs API server and return the response back.
6
+ # While sending respose back to receiver it will create the virtual models
7
+ # from Com::Nbos::Api::DataModels
8
+ class WavelabsClientApi::Client::Api::Core::AuthApi < WavelabsClientApi::Client::Api::Core::BaseApi
9
+
10
+ # Api Server Authentication End Point URIs
11
+ AUTH_TOKEN_URI = "/oauth/token"
12
+ TOKEN_VALIDATION_URI = "/api/oauth/v0/tokens"
13
+ LOGIN_URI = "/api/identity/v0/auth/login"
14
+ LOGOUT_URI = "/api/identity/v0/auth/logout"
15
+ CHANGE_PASSWORD_URI = "/api/identity/v0/auth/changePassword"
16
+ FORGOT_PASSWORD_URI = "/api/identity/v0/auth/forgotPassword"
17
+ RESET_PASSWORD_URI = "/api/identity/v0/auth/resetPassword"
18
+
19
+
20
+
21
+ #Method to get Access Token
22
+ def get_auth_token(grant_type, scope, clientId = nil, clientSecret = nil)
23
+ url_path = base_api_url(AUTH_TOKEN_URI)
24
+ query_params = { :client_id => clientId || client_id,
25
+ :client_secret => clientSecret || client_secret,
26
+ :grant_type => grant_type,
27
+ :scope => scope
28
+ }
29
+ body = nil
30
+ begin
31
+ api_response = send_request('post', url_path, body , query_params)
32
+ details = api_response.code == 200 ? api_response.parsed_response : nil
33
+ token_model = create_token_model(details)
34
+ build_token_response(api_response, token_model)
35
+ rescue StandardError
36
+ token_model = create_token_model(nil)
37
+ token_model.message = "API Server is Down Please try After Some Time."
38
+ { status: 500, token: token_model}
39
+ end
40
+ end
41
+
42
+ # Method to validate both client & user token
43
+ def is_token_valid(tokeId, access_token)
44
+ url_path = base_api_url(TOKEN_VALIDATION_URI + "/#{tokeId}")
45
+ api_response = send_request_with_token('get', url_path, access_token)
46
+ details = api_response.code == 200 ? api_response.parsed_response : nil
47
+ token_model = create_token_details_model(details)
48
+ build_token_response(api_response, token_model)
49
+ end
50
+
51
+ def build_token_response(api_response, data_model)
52
+ begin
53
+ if api_response.code == 400
54
+ data_model.add_errors(api_response.parsed_response)
55
+ { status: 400, token: data_model}
56
+ else
57
+ data_model.add_messages(api_response.parsed_response)
58
+ { status: api_response.code, token: data_model}
59
+ end
60
+ rescue StandardError
61
+ data_model.message = "Internal Server Error Please Try After Some Time."
62
+ { status: 500, token: data_model}
63
+ end
64
+ end
65
+
66
+ # Api Call to Change Password request with access_token
67
+ def change_password(change_password_params, access_token)
68
+ url_path = base_api_url(CHANGE_PASSWORD_URI)
69
+ connection_options = { :password => change_password_params[:password],
70
+ :newPassword => change_password_params[:newPassword]
71
+ }
72
+ login_model = create_login_model(change_password_params)
73
+
74
+ api_response = send_request_with_token('post', url_path, access_token, connection_options.to_json)
75
+
76
+ build_password_response(api_response, login_model)
77
+ end
78
+
79
+
80
+ # Api Call to get Reset Password Instructions
81
+ def forgot_password(forgot_password_params, access_token)
82
+ url_path = base_api_url(FORGOT_PASSWORD_URI)
83
+ connection_options = { :email => forgot_password_params[:email] }
84
+ api_response = send_request_with_token('post', url_path, access_token, connection_options.to_json)
85
+ login_model = create_login_model(forgot_password_params)
86
+
87
+ build_password_response(api_response, login_model)
88
+ end
89
+
90
+ def build_password_response(api_response, data_model)
91
+ begin
92
+ if api_response.code == 400
93
+ data_model.add_errors(api_response.parsed_response)
94
+ { status: 400, login: data_model}
95
+ else
96
+ data_model.add_messages(api_response.parsed_response)
97
+ { status: api_response.code, login: data_model}
98
+ end
99
+ rescue StandardError
100
+ data_model.message = "Internal Server Error Please Try After Some Time."
101
+ { status: 500, login: data_model}
102
+ end
103
+ end
104
+
105
+
106
+ # Api Call To Login
107
+ def login(login_params = nil, access_token = nil)
108
+ login_model = create_login_model(login_params)
109
+
110
+ if login_params.present? && check_login_params(login_params)
111
+ url_path = base_api_url(LOGIN_URI)
112
+ connection_options = { :clientId => client_id,
113
+ :username => login_params[:username],
114
+ :password => login_params[:password]
115
+ }
116
+
117
+ api_response = send_request_with_token('post', url_path, access_token, connection_options.to_json)
118
+
119
+ begin
120
+ if api_response.code == 200
121
+ member_model = create_member_model(api_response.parsed_response, false)
122
+ { status: 200, member: member_model}
123
+ elsif api_response.code == 400
124
+ login_model.add_errors(api_response.parsed_response)
125
+ { status: 400, member: nil, login: login_model}
126
+ else
127
+ login_model.add_messages(api_response.parsed_response)
128
+ { status: api_response.code, login: login_model}
129
+ end
130
+ rescue StandardError
131
+ login_model.message = "Internal Server Error Please Try After Some Time."
132
+ { status: 500, login: login_model}
133
+ end
134
+
135
+ else
136
+ login_model.message = "Invalid login parameters"
137
+ { status: 500, login: login_model}
138
+ end
139
+
140
+ end
141
+
142
+
143
+ # Api Call To Logout with Access Token
144
+ def logout(access_token)
145
+ url_path = base_api_url(LOGOUT_URI)
146
+ api_response = send_request_with_token('get', url_path, access_token)
147
+ login_model = create_login_model(nil)
148
+
149
+ begin
150
+ if api_response.code == 200
151
+ login_model.add_messages(api_response.parsed_response)
152
+ {status: 200, login: login_model}
153
+ else
154
+ login_model.add_messages(api_response.parsed_response)
155
+ {status: api_response.code, login: login_model}
156
+ end
157
+ rescue StandardError
158
+ login_model.message = "Internal Server Error Please Try After Some Time."
159
+ { status: 500, login: login_model}
160
+ end
161
+ end
162
+
163
+
164
+ # Need to Implement this based on Server Side Logic
165
+ def reset_password
166
+ url_path = base_api_url(RESET_PASSWORD_URI)
167
+ end
168
+
169
+
170
+ def check_login_params(login_params)
171
+
172
+ if login_params.length == 2 && [:username, :password] == login_params.keys || ["username", "password"] == login_params.keys
173
+ true
174
+ else
175
+ false
176
+ end
177
+ end
178
+
179
+ end