usman 0.3.23 → 0.3.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/usman/api/v1/contacts_controller.rb +116 -0
- data/app/controllers/usman/api/v1/docs_controller.rb +97 -0
- data/app/models/device.rb +1 -0
- data/app/models/registration.rb +1 -0
- data/app/models/user.rb +1 -0
- data/app/models/usman/contact.rb +78 -0
- data/app/serializers/contact_serializer.rb +12 -0
- data/app/views/usman/api/v1/docs/all_contacts/_neg_case_1.html.erb +34 -0
- data/app/views/usman/api/v1/docs/all_contacts/_pos_case_1.html.erb +67 -0
- data/app/views/usman/api/v1/docs/contacts_sync/_neg_case_1.html.erb +52 -0
- data/app/views/usman/api/v1/docs/contacts_sync/_pos_case_1.html.erb +53 -0
- data/app/views/usman/api/v1/docs/single_contacts/_neg_case_1.html.erb +33 -0
- data/app/views/usman/api/v1/docs/single_contacts/_pos_case_1.html.erb +47 -0
- data/config/locales/usman/api.en.yml +5 -1
- data/config/routes.rb +9 -0
- data/db/migrate/20171124071245_create_contacts.rb +24 -0
- data/lib/usman/version.rb +1 -1
- metadata +16 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58b44b778d452ed6091870274ebe07eee259b955
|
4
|
+
data.tar.gz: 6b861e63e0b1fe9b15c237fcf9cc942adb38de68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d99f6f25b5a0abbd550dd782a8feac4cfeb3e7e2336b3c0ed0185c43a66903c31a85b169c79f6f02899f2de733b0566c1d12472da5e5c47124034243dc9e3fc5
|
7
|
+
data.tar.gz: 12715344385c0f2357623a416af99cb94b8b4f45d7d2c7e38398ea2f4669b2d3a36fae6108093cffbc2ee5ca5b5e89fb20358dba56fe7a8d8b21b9365e79d0c4
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Usman
|
2
|
+
module Api
|
3
|
+
module V1
|
4
|
+
class ContactsController < Usman::Api::V1::BaseController
|
5
|
+
|
6
|
+
def sync
|
7
|
+
proc_code = Proc.new do
|
8
|
+
if @current_registration
|
9
|
+
unless @current_user
|
10
|
+
@success = false
|
11
|
+
@errors = {
|
12
|
+
heading: I18n.translate("api.profile.user_does_not_exists.heading"),
|
13
|
+
message: I18n.translate("api.profile.user_does_not_exists.message")
|
14
|
+
}
|
15
|
+
else
|
16
|
+
|
17
|
+
contacts = []
|
18
|
+
params[:contacts].each do |cnt|
|
19
|
+
contact = Usman::Contact.new
|
20
|
+
|
21
|
+
contact.name = cnt["name"]
|
22
|
+
contact.account_type = cnt["account_type"]
|
23
|
+
contact.email = cnt["email"]
|
24
|
+
contact.contact_number_1 = cnt["contact_number_1"]
|
25
|
+
contact.contact_number_2 = cnt["contact_number_2"]
|
26
|
+
contact.contact_number_3 = cnt["contact_number_3"]
|
27
|
+
contact.contact_number_4 = cnt["contact_number_4"]
|
28
|
+
|
29
|
+
contact.owner = @current_user
|
30
|
+
contact.done_deal_user = contact.get_done_deal_user
|
31
|
+
contact.registration = @current_registration
|
32
|
+
contact.device = @current_device
|
33
|
+
|
34
|
+
contact.save
|
35
|
+
contacts << contact if contact.done_deal_user_id
|
36
|
+
end
|
37
|
+
|
38
|
+
@success = true
|
39
|
+
@alert = {
|
40
|
+
heading: I18n.translate("api.contacts.synced_successfully.heading"),
|
41
|
+
message: I18n.translate("api.contacts.synced_successfully.message")
|
42
|
+
}
|
43
|
+
@data = ActiveModelSerializers::SerializableResource.new(contacts, each_serializer: ContactSerializer)
|
44
|
+
end
|
45
|
+
else
|
46
|
+
@success = false
|
47
|
+
@errors = {
|
48
|
+
heading: I18n.translate("api.profile.registration_details_missing.heading"),
|
49
|
+
message: I18n.translate("api.profile.registration_details_missing.message")
|
50
|
+
}
|
51
|
+
end
|
52
|
+
end
|
53
|
+
render_json_response(proc_code)
|
54
|
+
end
|
55
|
+
|
56
|
+
def index
|
57
|
+
proc_code = Proc.new do
|
58
|
+
if @current_registration
|
59
|
+
unless @current_user
|
60
|
+
@success = false
|
61
|
+
@errors = {
|
62
|
+
heading: I18n.translate("api.profile.user_does_not_exists.heading"),
|
63
|
+
message: I18n.translate("api.profile.user_does_not_exists.message")
|
64
|
+
}
|
65
|
+
else
|
66
|
+
@contacts = @current_user.contacts.page(@current_page).per(@per_page)
|
67
|
+
@success = true
|
68
|
+
@data = ActiveModelSerializers::SerializableResource.new(@contacts, each_serializer: ContactSerializer)
|
69
|
+
end
|
70
|
+
else
|
71
|
+
@success = false
|
72
|
+
@errors = {
|
73
|
+
heading: I18n.translate("api.profile.registration_details_missing.heading"),
|
74
|
+
message: I18n.translate("api.profile.registration_details_missing.message")
|
75
|
+
}
|
76
|
+
end
|
77
|
+
end
|
78
|
+
render_json_response(proc_code)
|
79
|
+
end
|
80
|
+
|
81
|
+
def show
|
82
|
+
proc_code = Proc.new do
|
83
|
+
if @current_registration
|
84
|
+
unless @current_user
|
85
|
+
@success = false
|
86
|
+
@errors = {
|
87
|
+
heading: I18n.translate("api.profile.user_does_not_exists.heading"),
|
88
|
+
message: I18n.translate("api.profile.user_does_not_exists.message")
|
89
|
+
}
|
90
|
+
else
|
91
|
+
@contact = @current_user.contacts.where(id: params[:id]).first || @current_user.contacts.build
|
92
|
+
@success = true
|
93
|
+
@data = ActiveModelSerializers::SerializableResource.new(@contact, serializer: ContactSerializer)
|
94
|
+
end
|
95
|
+
else
|
96
|
+
@success = false
|
97
|
+
@errors = {
|
98
|
+
heading: I18n.translate("api.profile.registration_details_missing.heading"),
|
99
|
+
message: I18n.translate("api.profile.registration_details_missing.message")
|
100
|
+
}
|
101
|
+
end
|
102
|
+
end
|
103
|
+
render_json_response(proc_code)
|
104
|
+
end
|
105
|
+
|
106
|
+
private
|
107
|
+
|
108
|
+
def permitted_params
|
109
|
+
params.permit(:name, :account_type, :email, :address, :contact_number_1, :contact_number_2, :contact_number_3, :contact_number_4)
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
@@ -207,6 +207,100 @@ module Usman
|
|
207
207
|
render 'kuppayam/api/docs/show'
|
208
208
|
end
|
209
209
|
|
210
|
+
|
211
|
+
def contacts_sync
|
212
|
+
set_title("Sync Contacts")
|
213
|
+
@request_type = "POST"
|
214
|
+
@end_point = "/api/v1/contacts/sync"
|
215
|
+
@description = <<-eos
|
216
|
+
This API sync all the contacts with donedeal backend
|
217
|
+
eos
|
218
|
+
|
219
|
+
@input_headers = {
|
220
|
+
"Content-Type" => { value: "application/json", description: "The MIME media type for JSON text is application/json. This is to make sure that a valid json is returned. The default encoding is UTF-8. " },
|
221
|
+
"Authorization" => { value: "Token token=\"103652edd6bbdc72b770d3c8cb88b18d\"", description: "Put the API Token here. You shall get the API token after registering your device" }
|
222
|
+
}
|
223
|
+
|
224
|
+
@input_params = {
|
225
|
+
contacts: {
|
226
|
+
mandatory: true,
|
227
|
+
description: "Json array of contact informations",
|
228
|
+
example: '[
|
229
|
+
{
|
230
|
+
"name": "Mohanlala",
|
231
|
+
"account_type": "com.mollywood",
|
232
|
+
"email": "mohanlal@gmail.com",
|
233
|
+
"address": "xyz, str, efg",
|
234
|
+
"contact_number_1": "87393993884",
|
235
|
+
"contact_number_2":"9846557465"
|
236
|
+
},
|
237
|
+
{
|
238
|
+
"name": "Mammukka",
|
239
|
+
"account_type": "com.mollywood1",
|
240
|
+
"email": "mammukka@gmail.com",
|
241
|
+
"address": "xyz, str, efg",
|
242
|
+
"contact_number_1": "7046338475",
|
243
|
+
"contact_number_2":"8086500502"
|
244
|
+
}
|
245
|
+
]',
|
246
|
+
default: ""
|
247
|
+
},
|
248
|
+
}
|
249
|
+
|
250
|
+
@example_path = "usman/api/v1/docs/"
|
251
|
+
@examples = ["pos_case_1", "neg_case_1"]
|
252
|
+
|
253
|
+
set_nav("docs/usman/contacts_sync")
|
254
|
+
|
255
|
+
render 'kuppayam/api/docs/show'
|
256
|
+
end
|
257
|
+
|
258
|
+
def all_contacts
|
259
|
+
set_title("Get All Contacts")
|
260
|
+
@request_type = "GET"
|
261
|
+
@end_point = "/api/v1/contacts"
|
262
|
+
@description = <<-eos
|
263
|
+
This API fetch all the contacts of coresponding logged user
|
264
|
+
eos
|
265
|
+
|
266
|
+
@input_headers = {
|
267
|
+
"Content-Type" => { value: "application/json", description: "The MIME media type for JSON text is application/json. This is to make sure that a valid json is returned. The default encoding is UTF-8. " },
|
268
|
+
"Authorization" => { value: "Token token=\"103652edd6bbdc72b770d3c8cb88b18d\"", description: "Put the API Token here. You shall get the API token after registering your device" }
|
269
|
+
}
|
270
|
+
|
271
|
+
@input_params = {}
|
272
|
+
|
273
|
+
@example_path = "usman/api/v1/docs/"
|
274
|
+
@examples = ["pos_case_1", "neg_case_1"]
|
275
|
+
|
276
|
+
set_nav("docs/usman/all_contacts")
|
277
|
+
|
278
|
+
render 'kuppayam/api/docs/show'
|
279
|
+
end
|
280
|
+
|
281
|
+
def single_contacts
|
282
|
+
set_title("Single Contacts")
|
283
|
+
@request_type = "GET"
|
284
|
+
@end_point = "/api/v1/contacts/:id"
|
285
|
+
@description = <<-eos
|
286
|
+
This API fetch single contacts from the Data base coresponding logged user
|
287
|
+
eos
|
288
|
+
|
289
|
+
@input_headers = {
|
290
|
+
"Content-Type" => { value: "application/json", description: "The MIME media type for JSON text is application/json. This is to make sure that a valid json is returned. The default encoding is UTF-8. " },
|
291
|
+
"Authorization" => { value: "Token token=\"103652edd6bbdc72b770d3c8cb88b18d\"", description: "Put the API Token here. You shall get the API token after registering your device" }
|
292
|
+
}
|
293
|
+
|
294
|
+
@input_params = {}
|
295
|
+
|
296
|
+
@example_path = "usman/api/v1/docs/"
|
297
|
+
@examples = ["pos_case_1", "neg_case_1"]
|
298
|
+
|
299
|
+
set_nav("docs/usman/single_contacts")
|
300
|
+
|
301
|
+
render 'kuppayam/api/docs/show'
|
302
|
+
end
|
303
|
+
|
210
304
|
def upload_profile_picture_base64
|
211
305
|
set_title("Upload Profile Picture API (base64)")
|
212
306
|
@request_type = "POST"
|
@@ -292,6 +386,9 @@ module Usman
|
|
292
386
|
create_profile: { nav_class: "docs/usman/create_profile", icon_class: "fa-user", url: usman.docs_api_v1_create_profile_path, text: "Create Profile API"},
|
293
387
|
update_profile: { nav_class: "docs/usman/update_profile", icon_class: "fa-user", url: usman.docs_api_v1_update_profile_path, text: "Update Profile API"},
|
294
388
|
get_profile_info: { nav_class: "docs/usman/get_profile_info", icon_class: "fa-user", url: usman.docs_api_v1_get_profile_info_path, text: "Get Profile Info API"},
|
389
|
+
contacts_sync: { nav_class: "docs/usman/contacts_sync", icon_class: "fa-user", url: usman.docs_api_v1_contacts_sync_path, text: "Contact Syncing"},
|
390
|
+
all_contacts: { nav_class: "docs/usman/all_contacts", icon_class: "fa-user", url: usman.docs_api_v1_all_contacts_path, text: "Get All Contacts"},
|
391
|
+
single_contacts: { nav_class: "docs/usman/single_contacts", icon_class: "fa-user", url: usman.docs_api_v1_single_contacts_path, text: "Single Contact"},
|
295
392
|
upload_profile_picture_base64: { nav_class: "docs/usman/upload_profile_picture_base64", icon_class: "fa-photo", url: usman.docs_api_v1_upload_profile_picture_base64_path, text: "Upload Profile Picture (Base64)"},
|
296
393
|
upload_profile_picture: { nav_class: "docs/usman/upload_profile_picture", icon_class: "fa-photo", url: usman.docs_api_v1_upload_profile_picture_path, text: "Upload Profile Picture"},
|
297
394
|
delete_profile_picture: { nav_class: "docs/usman/delete_profile_picture", icon_class: "fa-photo", url: usman.docs_api_v1_delete_profile_picture_path, text: "Remove Profile Picture"}
|
data/app/models/device.rb
CHANGED
data/app/models/registration.rb
CHANGED
@@ -24,6 +24,7 @@ class Registration < ApplicationRecord
|
|
24
24
|
belongs_to :country
|
25
25
|
belongs_to :city, optional: true
|
26
26
|
has_many :devices
|
27
|
+
has_many :contacts, class_name: "Usman::Contact"
|
27
28
|
|
28
29
|
# Validations
|
29
30
|
validates :dialing_prefix, presence: true, length: {minimum: 2, maximum: 4}
|
data/app/models/user.rb
CHANGED
@@ -62,6 +62,7 @@ class User < Usman::ApplicationRecord
|
|
62
62
|
has_many :features, through: :permissions
|
63
63
|
has_many :devices
|
64
64
|
has_one :registration
|
65
|
+
has_many :contacts, class_name: "Usman::Contact", foreign_key: :owner_id
|
65
66
|
has_and_belongs_to_many :roles
|
66
67
|
belongs_to :country, optional: true
|
67
68
|
belongs_to :city, optional: true
|
@@ -0,0 +1,78 @@
|
|
1
|
+
class Usman::Contact < Usman::ApplicationRecord
|
2
|
+
|
3
|
+
# Set Table Name
|
4
|
+
self.table_name = "contacts"
|
5
|
+
|
6
|
+
# Associations
|
7
|
+
belongs_to :owner, class_name: "User"
|
8
|
+
belongs_to :done_deal_user, class_name: "User", optional: true
|
9
|
+
belongs_to :registration, optional: true
|
10
|
+
belongs_to :device, optional: true
|
11
|
+
|
12
|
+
# Validations
|
13
|
+
validates :name, presence: true, length: {maximum: 512}
|
14
|
+
validates :account_type, length: {maximum: 256}
|
15
|
+
|
16
|
+
validates :email, length: {maximum: 256}
|
17
|
+
validate_email :email
|
18
|
+
validates :address, length: {maximum: 512}
|
19
|
+
|
20
|
+
validates :contact_number_1, presence: true, length: {maximum: 24}
|
21
|
+
validates :contact_number_2, length: {maximum: 24}
|
22
|
+
validates :contact_number_3, length: {maximum: 24}
|
23
|
+
validates :contact_number_4, length: {maximum: 24}
|
24
|
+
|
25
|
+
# ------------------
|
26
|
+
# Class Methods
|
27
|
+
# ------------------
|
28
|
+
|
29
|
+
# return an active record relation object with the search query in its where clause
|
30
|
+
# Return the ActiveRecord::Relation object
|
31
|
+
# == Examples
|
32
|
+
# >>> Contact.search(query)
|
33
|
+
# => ActiveRecord::Relation object
|
34
|
+
scope :search, lambda {|query| where("LOWER(contacts.name) LIKE LOWER('%#{query}%') OR
|
35
|
+
LOWER(contacts.contact_number_1) LIKE LOWER('%#{query}%') OR
|
36
|
+
LOWER(contacts.contact_number_2) LIKE LOWER('%#{query}%') OR
|
37
|
+
LOWER(contacts.contact_number_3) LIKE LOWER('%#{query}%') OR
|
38
|
+
LOWER(contacts.contact_number_4) LIKE LOWER('%#{query}%') OR
|
39
|
+
LOWER(contacts.email) LIKE LOWER('%#{query}%') OR
|
40
|
+
LOWER(contacts.account_type) LIKE LOWER('%#{query}%')")}
|
41
|
+
|
42
|
+
# ------------------
|
43
|
+
# Instance Methods
|
44
|
+
# ------------------
|
45
|
+
|
46
|
+
# Permission Methods
|
47
|
+
# ------------------
|
48
|
+
|
49
|
+
def can_be_edited?
|
50
|
+
false
|
51
|
+
end
|
52
|
+
|
53
|
+
def can_be_deleted?
|
54
|
+
false
|
55
|
+
end
|
56
|
+
|
57
|
+
# Authentication Methods
|
58
|
+
# ----------------------
|
59
|
+
|
60
|
+
# Other Methods
|
61
|
+
# -------------
|
62
|
+
|
63
|
+
# * Return full name
|
64
|
+
# == Examples
|
65
|
+
# >>> contact.display_name
|
66
|
+
# => "<NAME>"
|
67
|
+
def display_name
|
68
|
+
"#{self.name}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def get_done_deal_user
|
72
|
+
arr = [self.contact_number_1, self.contact_number_2, self.contact_number_3, self.contact_number_4].compact.uniq
|
73
|
+
return if arr.first.nil?
|
74
|
+
reg = Registration.where("CONCAT_WS('', dialing_prefix, mobile_number) IN (?)", arr).first
|
75
|
+
return reg && reg.user ? reg.user : nil
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ContactSerializer < ActiveModel::Serializer
|
2
|
+
include NullAttributeReplacer
|
3
|
+
attributes :id, :name, :account_type, :email, :address, :contact_number_1, :contact_number_2, :contact_number_3, :contact_number_4
|
4
|
+
|
5
|
+
has_one :profile_picture, class_name: "Image::ProfilePicture", serializer: ProfilePictureSerializer do
|
6
|
+
if object.done_deal_user && object.done_deal_user.profile_picture
|
7
|
+
object.done_deal_user.profile_picture
|
8
|
+
else
|
9
|
+
Image::ProfilePicture.new
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 1 - should set proper errors if api token is not present"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
Example:
|
7
|
+
|
8
|
+
Authorization: nil
|
9
|
+
GET #{request.base_url}/api/v1/contacts
|
10
|
+
{
|
11
|
+
}
|
12
|
+
|
13
|
+
Contact API fetch the synced data from the data base
|
14
|
+
eos
|
15
|
+
|
16
|
+
api_output = <<-eos
|
17
|
+
{
|
18
|
+
"success": false,
|
19
|
+
"errors": {
|
20
|
+
"heading": "Invalid API Token",
|
21
|
+
"message": "Use the API Token you have received after accepting the terms and agreement"
|
22
|
+
}
|
23
|
+
}
|
24
|
+
eos
|
25
|
+
|
26
|
+
%>
|
27
|
+
|
28
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
29
|
+
negative_case: true,
|
30
|
+
example_id: "neg_case_1",
|
31
|
+
api_title: api_title,
|
32
|
+
api_input: api_input,
|
33
|
+
api_output: api_output
|
34
|
+
} %>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - API fetch all contacts corresponding to the logged user from the Data Base"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
Example:
|
7
|
+
|
8
|
+
Authorization: Token token="103652edd6bbdc72b770d3c8cb88b18d"
|
9
|
+
GET #{request.base_url}/api/v1/contacts
|
10
|
+
|
11
|
+
|
12
|
+
Contact API fetch all synced contacts from the data base
|
13
|
+
eos
|
14
|
+
|
15
|
+
api_output = <<-eos
|
16
|
+
{
|
17
|
+
"success": true,
|
18
|
+
"data": [
|
19
|
+
{
|
20
|
+
"id": 1,
|
21
|
+
"name": "Mohanlal",
|
22
|
+
"account_type": "com.mollywood",
|
23
|
+
"email": "mohanlal@gmail.com",
|
24
|
+
"address": "",
|
25
|
+
"contact_number_1": "87393993884",
|
26
|
+
"contact_number_2": "9846557465",
|
27
|
+
"contact_number_3": "",
|
28
|
+
"contact_number_4": "",
|
29
|
+
"profile_picture": {
|
30
|
+
"id": "",
|
31
|
+
"created_at": "",
|
32
|
+
"profile_id": "",
|
33
|
+
"image_large_path": "",
|
34
|
+
"image_small_path": ""
|
35
|
+
}
|
36
|
+
},
|
37
|
+
{
|
38
|
+
"id": 2,
|
39
|
+
"name": "Mammukka",
|
40
|
+
"account_type": "com.mollywood1",
|
41
|
+
"email": "mammukka@gmail.com",
|
42
|
+
"address": "",
|
43
|
+
"contact_number_1": "808650052",
|
44
|
+
"contact_number_2": "7488374657",
|
45
|
+
"contact_number_3": "",
|
46
|
+
"contact_number_4": "",
|
47
|
+
"profile_picture": {
|
48
|
+
"id": "",
|
49
|
+
"created_at": "",
|
50
|
+
"profile_id": "",
|
51
|
+
"image_large_path": "",
|
52
|
+
"image_small_path": ""
|
53
|
+
}
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
eos
|
58
|
+
|
59
|
+
%>
|
60
|
+
|
61
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
62
|
+
negative_case: false,
|
63
|
+
example_id: "pos_case_1",
|
64
|
+
api_title: api_title,
|
65
|
+
api_input: api_input,
|
66
|
+
api_output: api_output
|
67
|
+
} %>
|
@@ -0,0 +1,52 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 1 - should set proper errors if api token is not present"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
Example:
|
7
|
+
|
8
|
+
Authorization: nil
|
9
|
+
POST #{request.base_url}/api/v1/contacts/sync
|
10
|
+
{
|
11
|
+
"contacts": [
|
12
|
+
{
|
13
|
+
"name": "sanoop",
|
14
|
+
"account_type": "com.mollywood",
|
15
|
+
"email": "san@gmail.com",
|
16
|
+
"address": "xyz, str, efg",
|
17
|
+
"contact_number_1": "87393993884",
|
18
|
+
"contact_number_2":"9846557465"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "arjun",
|
22
|
+
"account_type": "com.mollywood1",
|
23
|
+
"email": "arj@gmail.com",
|
24
|
+
"address": "xyz, str, efg",
|
25
|
+
"contact_number_1": "77777777",
|
26
|
+
"contact_number_2":"999999999"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
|
31
|
+
Contact sync API sync the mobile contact with donedeal backend
|
32
|
+
eos
|
33
|
+
|
34
|
+
api_output = <<-eos
|
35
|
+
{
|
36
|
+
"success": false,
|
37
|
+
"errors": {
|
38
|
+
"heading": "Invalid API Token",
|
39
|
+
"message": "Use the API Token you have received after accepting the terms and agreement"
|
40
|
+
}
|
41
|
+
}
|
42
|
+
eos
|
43
|
+
|
44
|
+
%>
|
45
|
+
|
46
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
47
|
+
negative_case: true,
|
48
|
+
example_id: "neg_case_1",
|
49
|
+
api_title: api_title,
|
50
|
+
api_input: api_input,
|
51
|
+
api_output: api_output
|
52
|
+
} %>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - Sync phone contact with donedeal backend"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
Example:
|
7
|
+
|
8
|
+
Authorization: Token token="103652edd6bbdc72b770d3c8cb88b18d"
|
9
|
+
POST #{request.base_url}/api/v1/contacts/sync
|
10
|
+
{
|
11
|
+
"contacts": [
|
12
|
+
{
|
13
|
+
"name": "sanoop",
|
14
|
+
"account_type": "com.mollywood",
|
15
|
+
"email": "san@gmail.com",
|
16
|
+
"address": "xyz, str, efg",
|
17
|
+
"contact_number_1": "87393993884",
|
18
|
+
"contact_number_2":"9846557465"
|
19
|
+
},
|
20
|
+
{
|
21
|
+
"name": "arjun",
|
22
|
+
"account_type": "com.mollywood1",
|
23
|
+
"email": "arj@gmail.com",
|
24
|
+
"address": "xyz, str, efg",
|
25
|
+
"contact_number_1": "77777777",
|
26
|
+
"contact_number_2":"999999999"
|
27
|
+
}
|
28
|
+
]
|
29
|
+
}
|
30
|
+
|
31
|
+
Contact sync API sync the mobile contact with donedeal backend
|
32
|
+
eos
|
33
|
+
|
34
|
+
api_output = <<-eos
|
35
|
+
{
|
36
|
+
"success": true,
|
37
|
+
"alert": {
|
38
|
+
"heading": "The Contacts has been synced successfully",
|
39
|
+
"message": "You may now store the done deal user id of these contacts returned in this response"
|
40
|
+
},
|
41
|
+
"data": []
|
42
|
+
}
|
43
|
+
eos
|
44
|
+
|
45
|
+
%>
|
46
|
+
|
47
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
48
|
+
negative_case: false,
|
49
|
+
example_id: "pos_case_1",
|
50
|
+
api_title: api_title,
|
51
|
+
api_input: api_input,
|
52
|
+
api_output: api_output
|
53
|
+
} %>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Negative Case - 1 - should set proper errors if api token is not present"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
Example:
|
7
|
+
|
8
|
+
Authorization: nil
|
9
|
+
GET #{request.base_url}/api/v1/contacts/1
|
10
|
+
|
11
|
+
|
12
|
+
Single contact API fetch single contact from back end
|
13
|
+
eos
|
14
|
+
|
15
|
+
api_output = <<-eos
|
16
|
+
{
|
17
|
+
"success": false,
|
18
|
+
"errors": {
|
19
|
+
"heading": "Invalid API Token",
|
20
|
+
"message": "Use the API Token you have received after accepting the terms and agreement"
|
21
|
+
}
|
22
|
+
}
|
23
|
+
eos
|
24
|
+
|
25
|
+
%>
|
26
|
+
|
27
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
28
|
+
negative_case: true,
|
29
|
+
example_id: "neg_case_1",
|
30
|
+
api_title: api_title,
|
31
|
+
api_input: api_input,
|
32
|
+
api_output: api_output
|
33
|
+
} %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<%
|
2
|
+
|
3
|
+
api_title = "Positive Case - 1 - Sync phone contact with donedeal backend"
|
4
|
+
|
5
|
+
api_input = <<-eos
|
6
|
+
Example:
|
7
|
+
|
8
|
+
Authorization: nil
|
9
|
+
GET #{request.base_url}/api/v1/contacts/1
|
10
|
+
|
11
|
+
|
12
|
+
Single contact API fetch single contact from back end
|
13
|
+
eos
|
14
|
+
|
15
|
+
api_output = <<-eos
|
16
|
+
{
|
17
|
+
"success": true,
|
18
|
+
"data": {
|
19
|
+
"id": 1,
|
20
|
+
"name": "Mohanlal",
|
21
|
+
"account_type": "com.mollywood",
|
22
|
+
"email": "mohanlal@gmail.com",
|
23
|
+
"address": "",
|
24
|
+
"contact_number_1": "87393993884",
|
25
|
+
"contact_number_2": "9846557465",
|
26
|
+
"contact_number_3": "",
|
27
|
+
"contact_number_4": "",
|
28
|
+
"profile_picture": {
|
29
|
+
"id": "",
|
30
|
+
"created_at": "",
|
31
|
+
"profile_id": "",
|
32
|
+
"image_large_path": "",
|
33
|
+
"image_small_path": ""
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
eos
|
38
|
+
|
39
|
+
%>
|
40
|
+
|
41
|
+
<%= render partial: "kuppayam/api/docs/example", locals: {
|
42
|
+
negative_case: false,
|
43
|
+
example_id: "pos_case_1",
|
44
|
+
api_title: api_title,
|
45
|
+
api_input: api_input,
|
46
|
+
api_output: api_output
|
47
|
+
} %>
|
@@ -108,4 +108,8 @@ en:
|
|
108
108
|
message: "You may use Profile Picture Upload API to add one again"
|
109
109
|
profile_picture_does_not_exists:
|
110
110
|
heading: "Profile Picture doesn't exists"
|
111
|
-
message: "You are trying to destroy a profile picture when it doesn't exist"
|
111
|
+
message: "You are trying to destroy a profile picture when it doesn't exist"
|
112
|
+
contacts:
|
113
|
+
synced_successfully:
|
114
|
+
heading: "The Contacts has been synced successfully"
|
115
|
+
message: "You may now store the done deal user id of these contacts returned in this response"
|
data/config/routes.rb
CHANGED
@@ -60,6 +60,11 @@ Usman::Engine.routes.draw do
|
|
60
60
|
put :update_profile, :controller => "profile", as: :update_profile
|
61
61
|
get :profile_info, :controller => "profile", as: :profile_info
|
62
62
|
|
63
|
+
# Contacts
|
64
|
+
post 'contacts/sync', :controller => "contacts", action: :sync, as: :sync_contacts
|
65
|
+
get 'contacts', :controller => "contacts", action: :index, as: :contacts
|
66
|
+
get 'contacts/:id', :controller => "contacts", action: :show, as: :contact
|
67
|
+
|
63
68
|
# Profile Picture
|
64
69
|
post 'profile/profile_picture_base64', :controller => "profile_picture", action: :profile_picture_base64, as: :profile_picture_base64
|
65
70
|
post 'profile/profile_picture', :controller => "profile_picture", action: :profile_picture, as: :profile_picture
|
@@ -79,6 +84,10 @@ Usman::Engine.routes.draw do
|
|
79
84
|
get 'update_profile', :controller => "docs"
|
80
85
|
get 'get_profile_info', :controller => "docs"
|
81
86
|
|
87
|
+
get 'contacts_sync', :controller => "docs"
|
88
|
+
get 'all_contacts', :controller => "docs"
|
89
|
+
get 'single_contacts', :controller => "docs"
|
90
|
+
|
82
91
|
get 'upload_profile_picture_base64', :controller => "docs"
|
83
92
|
get 'upload_profile_picture', :controller => "docs"
|
84
93
|
get 'delete_profile_picture', :controller => "docs"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class CreateContacts < ActiveRecord::Migration[5.1]
|
2
|
+
def change
|
3
|
+
create_table :contacts do |t|
|
4
|
+
|
5
|
+
t.string :name, limit: 512
|
6
|
+
|
7
|
+
t.string :account_type, null: true, limit: 256
|
8
|
+
|
9
|
+
t.string :email, :null => true, limit: 256
|
10
|
+
t.string :address, :null => true, limit: 512
|
11
|
+
|
12
|
+
t.references :owner, references: :user
|
13
|
+
t.references :done_deal_user, references: :user
|
14
|
+
t.references :registration
|
15
|
+
t.references :device
|
16
|
+
|
17
|
+
t.string :contact_number_1, :null => false, :limit=>24
|
18
|
+
t.string :contact_number_2, :null => true, :limit=>24
|
19
|
+
t.string :contact_number_3, :null => true, :limit=>24
|
20
|
+
t.string :contact_number_4, :null => true, :limit=>24
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/usman/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: usman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.24
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kpvarma
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
version: '0.1'
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.1.
|
110
|
+
version: 0.1.26
|
111
111
|
type: :runtime
|
112
112
|
prerelease: false
|
113
113
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -117,7 +117,7 @@ dependencies:
|
|
117
117
|
version: '0.1'
|
118
118
|
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version: 0.1.
|
120
|
+
version: 0.1.26
|
121
121
|
- !ruby/object:Gem::Dependency
|
122
122
|
name: pattana
|
123
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,7 +127,7 @@ dependencies:
|
|
127
127
|
version: '0.1'
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.1.
|
130
|
+
version: 0.1.20
|
131
131
|
type: :runtime
|
132
132
|
prerelease: false
|
133
133
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -137,7 +137,7 @@ dependencies:
|
|
137
137
|
version: '0.1'
|
138
138
|
- - ">="
|
139
139
|
- !ruby/object:Gem::Version
|
140
|
-
version: 0.1.
|
140
|
+
version: 0.1.20
|
141
141
|
- !ruby/object:Gem::Dependency
|
142
142
|
name: bcrypt
|
143
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -421,6 +421,7 @@ files:
|
|
421
421
|
- app/assets/sketches/logo.sketch
|
422
422
|
- app/controllers/usman/admin_controller.rb
|
423
423
|
- app/controllers/usman/api/v1/base_controller.rb
|
424
|
+
- app/controllers/usman/api/v1/contacts_controller.rb
|
424
425
|
- app/controllers/usman/api/v1/docs_controller.rb
|
425
426
|
- app/controllers/usman/api/v1/profile_controller.rb
|
426
427
|
- app/controllers/usman/api/v1/profile_picture_controller.rb
|
@@ -451,6 +452,8 @@ files:
|
|
451
452
|
- app/models/role.rb
|
452
453
|
- app/models/user.rb
|
453
454
|
- app/models/usman/application_record.rb
|
455
|
+
- app/models/usman/contact.rb
|
456
|
+
- app/serializers/contact_serializer.rb
|
454
457
|
- app/serializers/owner_serializer.rb
|
455
458
|
- app/serializers/profile_picture_serializer.rb
|
456
459
|
- app/serializers/profile_serializer.rb
|
@@ -469,6 +472,10 @@ files:
|
|
469
472
|
- app/views/usman/api/v1/docs/accept_tac/_neg_case_2.html.erb
|
470
473
|
- app/views/usman/api/v1/docs/accept_tac/_neg_case_3.html.erb
|
471
474
|
- app/views/usman/api/v1/docs/accept_tac/_pos_case_1.html.erb
|
475
|
+
- app/views/usman/api/v1/docs/all_contacts/_neg_case_1.html.erb
|
476
|
+
- app/views/usman/api/v1/docs/all_contacts/_pos_case_1.html.erb
|
477
|
+
- app/views/usman/api/v1/docs/contacts_sync/_neg_case_1.html.erb
|
478
|
+
- app/views/usman/api/v1/docs/contacts_sync/_pos_case_1.html.erb
|
472
479
|
- app/views/usman/api/v1/docs/create_profile/_neg_case_1.html.erb
|
473
480
|
- app/views/usman/api/v1/docs/create_profile/_neg_case_2.html.erb
|
474
481
|
- app/views/usman/api/v1/docs/create_profile/_neg_case_3.html.erb
|
@@ -493,6 +500,8 @@ files:
|
|
493
500
|
- app/views/usman/api/v1/docs/resend_otp/_neg_case_3.html.erb
|
494
501
|
- app/views/usman/api/v1/docs/resend_otp/_neg_case_4.html.erb
|
495
502
|
- app/views/usman/api/v1/docs/resend_otp/_pos_case_1.html.erb
|
503
|
+
- app/views/usman/api/v1/docs/single_contacts/_neg_case_1.html.erb
|
504
|
+
- app/views/usman/api/v1/docs/single_contacts/_pos_case_1.html.erb
|
496
505
|
- app/views/usman/api/v1/docs/update_profile/_neg_case_1.html.erb
|
497
506
|
- app/views/usman/api/v1/docs/update_profile/_neg_case_2.html.erb
|
498
507
|
- app/views/usman/api/v1/docs/update_profile/_neg_case_3.html.erb
|
@@ -577,6 +586,7 @@ files:
|
|
577
586
|
- db/migrate/20170929083234_add_categorisable_to_features.rb
|
578
587
|
- db/migrate/20170929083235_change_disabled_to_removed_features.rb
|
579
588
|
- db/migrate/20170929083236_add_country_city_to_users.rb
|
589
|
+
- db/migrate/20171124071245_create_contacts.rb
|
580
590
|
- lib/tasks/usman/data.rake
|
581
591
|
- lib/tasks/usman/master_data.rake
|
582
592
|
- lib/temp/features.rake
|