Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
App16
iOS
Commits
925add2f
Commit
925add2f
authored
Mar 25, 2020
by
Grigor Aghabalyan
⚽
Browse files
Feat: add forms list api
parent
cf2d80e4
Changes
6
Hide whitespace changes
Inline
Side-by-side
App16.xcodeproj/project.pbxproj
View file @
925add2f
...
@@ -7,6 +7,8 @@
...
@@ -7,6 +7,8 @@
objects = {
objects = {
/* Begin PBXBuildFile section */
/* Begin PBXBuildFile section */
C5D2A725242B077100825031 /* FormsService.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D2A724242B077100825031 /* FormsService.swift */; };
C5D2A727242B0A2300825031 /* FormsResponse.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D2A726242B0A2300825031 /* FormsResponse.swift */; };
C5D6914E242AA091004268C3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D6914D242AA091004268C3 /* AppDelegate.swift */; };
C5D6914E242AA091004268C3 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D6914D242AA091004268C3 /* AppDelegate.swift */; };
C5D69150242AA091004268C3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D6914F242AA091004268C3 /* SceneDelegate.swift */; };
C5D69150242AA091004268C3 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C5D6914F242AA091004268C3 /* SceneDelegate.swift */; };
C5D69155242AA091004268C3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C5D69153242AA091004268C3 /* Main.storyboard */; };
C5D69155242AA091004268C3 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C5D69153242AA091004268C3 /* Main.storyboard */; };
...
@@ -53,6 +55,8 @@
...
@@ -53,6 +55,8 @@
57DE28D9ACEB4E61AAE67E58 /* Pods-App16.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App16.debug.xcconfig"; path = "Target Support Files/Pods-App16/Pods-App16.debug.xcconfig"; sourceTree = "<group>"; };
57DE28D9ACEB4E61AAE67E58 /* Pods-App16.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App16.debug.xcconfig"; path = "Target Support Files/Pods-App16/Pods-App16.debug.xcconfig"; sourceTree = "<group>"; };
AC947C811CE3C096F8981C77 /* Pods_App16.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App16.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AC947C811CE3C096F8981C77 /* Pods_App16.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_App16.framework; sourceTree = BUILT_PRODUCTS_DIR; };
AF4BB414838A78D615C7E656 /* Pods-App16.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App16.release.xcconfig"; path = "Target Support Files/Pods-App16/Pods-App16.release.xcconfig"; sourceTree = "<group>"; };
AF4BB414838A78D615C7E656 /* Pods-App16.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-App16.release.xcconfig"; path = "Target Support Files/Pods-App16/Pods-App16.release.xcconfig"; sourceTree = "<group>"; };
C5D2A724242B077100825031 /* FormsService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormsService.swift; sourceTree = "<group>"; };
C5D2A726242B0A2300825031 /* FormsResponse.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormsResponse.swift; sourceTree = "<group>"; };
C5D6914A242AA091004268C3 /* App16.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App16.app; sourceTree = BUILT_PRODUCTS_DIR; };
C5D6914A242AA091004268C3 /* App16.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = App16.app; sourceTree = BUILT_PRODUCTS_DIR; };
C5D6914D242AA091004268C3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C5D6914D242AA091004268C3 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
C5D6914F242AA091004268C3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
C5D6914F242AA091004268C3 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
...
@@ -205,6 +209,7 @@
...
@@ -205,6 +209,7 @@
children = (
children = (
C5D691BD242AE510004268C3 /* FormCreateService.swift */,
C5D691BD242AE510004268C3 /* FormCreateService.swift */,
C5D691C1242AF07F004268C3 /* CurrentFormService.swift */,
C5D691C1242AF07F004268C3 /* CurrentFormService.swift */,
C5D2A724242B077100825031 /* FormsService.swift */,
);
);
path = Services;
path = Services;
sourceTree = "<group>";
sourceTree = "<group>";
...
@@ -334,6 +339,7 @@
...
@@ -334,6 +339,7 @@
C5D691BA242AE1D1004268C3 /* Form */ = {
C5D691BA242AE1D1004268C3 /* Form */ = {
isa = PBXGroup;
isa = PBXGroup;
children = (
children = (
C5D2A726242B0A2300825031 /* FormsResponse.swift */,
C5D691BB242AE1F8004268C3 /* FormCreateRequestForm.swift */,
C5D691BB242AE1F8004268C3 /* FormCreateRequestForm.swift */,
C5D691BF242AE5E2004268C3 /* FormCreateResponse.swift */,
C5D691BF242AE5E2004268C3 /* FormCreateResponse.swift */,
C5D691C3242AF0B1004268C3 /* CurentFormRequestForm.swift */,
C5D691C3242AF0B1004268C3 /* CurentFormRequestForm.swift */,
...
@@ -485,6 +491,8 @@
...
@@ -485,6 +491,8 @@
C5D69173242AA539004268C3 /* BaseService.swift in Sources */,
C5D69173242AA539004268C3 /* BaseService.swift in Sources */,
C5D691A1242AAE12004268C3 /* MainViewController.swift in Sources */,
C5D691A1242AAE12004268C3 /* MainViewController.swift in Sources */,
C5D69194242AAD00004268C3 /* SingleFormViewController.swift in Sources */,
C5D69194242AAD00004268C3 /* SingleFormViewController.swift in Sources */,
C5D2A727242B0A2300825031 /* FormsResponse.swift in Sources */,
C5D2A725242B077100825031 /* FormsService.swift in Sources */,
C5D691BE242AE510004268C3 /* FormCreateService.swift in Sources */,
C5D691BE242AE510004268C3 /* FormCreateService.swift in Sources */,
C5D691C2242AF07F004268C3 /* CurrentFormService.swift in Sources */,
C5D691C2242AF07F004268C3 /* CurrentFormService.swift in Sources */,
C5D69170242AA4E9004268C3 /* Config.swift in Sources */,
C5D69170242AA4E9004268C3 /* Config.swift in Sources */,
...
...
App16/Models/Form/FormCreateResponse.swift
View file @
925add2f
...
@@ -23,25 +23,27 @@ class FormCreateResponse: Mappable {
...
@@ -23,25 +23,27 @@ class FormCreateResponse: Mappable {
var
visitingLongitude
:
Double
?
var
visitingLongitude
:
Double
?
var
visitingReason
:
String
?
var
visitingReason
:
String
?
var
plannedReturnDatetime
:
String
?
var
plannedReturnDatetime
:
String
?
var
createdAt
:
String
?
required
init
?(
map
:
Map
)
{
}
required
init
?(
map
:
Map
)
{
}
init
()
{
}
init
()
{
}
func
mapping
(
map
:
Map
)
{
func
mapping
(
map
:
Map
)
{
deviceToken
<-
map
[
"device_token"
]
deviceToken
<-
map
[
"device_token"
]
firstName
<-
map
[
"first_name"
]
firstName
<-
map
[
"first_name"
]
lastName
<-
map
[
"last_name"
]
lastName
<-
map
[
"last_name"
]
middleName
<-
map
[
"middle_name"
]
middleName
<-
map
[
"middle_name"
]
outAddress
<-
map
[
"out_address"
]
outAddress
<-
map
[
"out_address"
]
outLatitude
<-
map
[
"out_latitude"
]
outLatitude
<-
map
[
"out_latitude"
]
outLongitude
<-
map
[
"out_longitude"
]
outLongitude
<-
map
[
"out_longitude"
]
outDatetime
<-
map
[
"out_datetime"
]
outDatetime
<-
map
[
"out_datetime"
]
visitingAddressAndName
<-
map
[
"visiting_address_and_name"
]
visitingAddressAndName
<-
map
[
"visiting_address_and_name"
]
visitingLatitude
<-
map
[
"visiting_latitude"
]
visitingLatitude
<-
map
[
"visiting_latitude"
]
visitingLongitude
<-
map
[
"visiting_longitude"
]
visitingLongitude
<-
map
[
"visiting_longitude"
]
visitingReason
<-
map
[
"visiting_reason"
]
visitingReason
<-
map
[
"visiting_reason"
]
plannedReturnDatetime
<-
map
[
"planned_return_datetime"
]
plannedReturnDatetime
<-
map
[
"planned_return_datetime"
]
createdAt
<-
map
[
"created_at"
]
}
}
}
}
...
...
App16/Models/Form/FormsResponse.swift
0 → 100644
View file @
925add2f
//
// FormsResponse.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import
ObjectMapper
class
FormsResponse
:
Mappable
{
var
data
:
[
FormCreateResponse
]?
required
init
?(
map
:
Map
)
{
}
init
()
{
}
func
mapping
(
map
:
Map
)
{
data
<-
map
[
"data"
]
}
}
enum
FormsResponseResponseData
<
FormCreateResponse
>
{
case
success
(
result
:
FormCreateResponse
)
case
base
(
response
:
BaseResponse
)
case
conflict
case
isOffline
}
App16/Services/FormsService.swift
0 → 100644
View file @
925add2f
//
// FormsService.swift
// App16
//
// Created by Grigor Aghabalyan on 3/25/20.
// Copyright © 2020 X-TECH. All rights reserved.
//
import
ObjectMapper
import
AlamofireObjectMapper
import
Alamofire
class
FormsService
{
static
let
shered
=
FormsService
()
func
retriveForms
(
data
:
CurentFormRequestForm
,
completion
:
@escaping
((
FormsResponseResponseData
<
FormsResponse
>
)
->
Void
))
{
BaseService
.
shared
.
get
(
endpoint
:
"/applications"
,
parameters
:
data
.
toJSON
(),
for
:
.
unsecure
)
.
responseString
{
(
response
)
in
print
(
response
.
result
.
value
??
"result value is nil"
)
if
let
responseHttp
=
response
.
response
,
let
value
=
response
.
result
.
value
{
if
let
baseResponse
=
BaseService
.
shared
.
checkBaseResponse
(
responseHttp
,
value
)
{
return
completion
(
.
base
(
response
:
baseResponse
))
}
}
else
{
return
completion
(
.
isOffline
)
}
switch
response
.
response
?
.
statusCode
??
400
{
case
200
...
201
:
if
let
value
=
response
.
result
.
value
,
let
data
=
Mapper
<
FormsResponse
>
()
.
map
(
JSONString
:
value
)
{
return
completion
(
.
success
(
result
:
data
))
}
return
completion
(
.
base
(
response
:
.
unexpectedError
(
error
:
ResponseUnexpectedError
.
mappingFailed
)))
default
:
return
completion
(
.
base
(
response
:
.
badRequest
))
}
}
}
}
App16/Views/Form/FormList/FormListViewController.swift
View file @
925add2f
...
@@ -15,6 +15,7 @@ class FormListViewController: UIViewController {
...
@@ -15,6 +15,7 @@ class FormListViewController: UIViewController {
// MARK: - Varibales
// MARK: - Varibales
private
let
formListCell
=
"FormListCell"
private
let
formListCell
=
"FormListCell"
var
dataSource
:
[
FormCreateResponse
]
=
[]
// MARK: - LifeCycle
// MARK: - LifeCycle
override
func
viewDidLoad
()
{
override
func
viewDidLoad
()
{
...
@@ -24,6 +25,10 @@ class FormListViewController: UIViewController {
...
@@ -24,6 +25,10 @@ class FormListViewController: UIViewController {
tableView
.
dataSource
=
self
tableView
.
dataSource
=
self
registerCelll
()
registerCelll
()
if
let
deviceId
=
UIDevice
.
current
.
identifierForVendor
?
.
uuidString
{
retriveCurentForm
(
deviceToken
:
deviceId
)
}
}
}
// MARK: - Register
// MARK: - Register
...
@@ -32,6 +37,31 @@ class FormListViewController: UIViewController {
...
@@ -32,6 +37,31 @@ class FormListViewController: UIViewController {
let
nib
=
UINib
(
nibName
:
formListCell
,
bundle
:
nil
)
let
nib
=
UINib
(
nibName
:
formListCell
,
bundle
:
nil
)
tableView
.
register
(
nib
,
forCellReuseIdentifier
:
formListCell
)
tableView
.
register
(
nib
,
forCellReuseIdentifier
:
formListCell
)
}
}
private
func
retriveCurentForm
(
deviceToken
:
String
)
{
let
form
=
CurentFormRequestForm
(
deviceToken
:
UIDevice
.
current
.
identifierForVendor
?
.
uuidString
)
FormsService
.
shered
.
retriveForms
(
data
:
form
)
{
(
responseData
)
in
switch
responseData
{
case
.
base
(
response
:
let
baseResposne
):
CheckBaseHelper
.
checkBaseResponse
(
baseResposne
,
viewController
:
self
)
case
.
success
(
let
response
):
self
.
dataSource
=
response
.
data
??
[]
DispatchQueue
.
main
.
async
{
self
.
tableView
.
reloadData
()
}
case
.
isOffline
:
//self.activityIndicator.stopAnimating()
return
case
.
conflict
:
//self.activityIndicator.stopAnimating()
return
}
}
}
}
}
extension
FormListViewController
:
UITableViewDataSource
{
extension
FormListViewController
:
UITableViewDataSource
{
...
@@ -39,12 +69,15 @@ extension FormListViewController: UITableViewDataSource {
...
@@ -39,12 +69,15 @@ extension FormListViewController: UITableViewDataSource {
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
func
tableView
(
_
tableView
:
UITableView
,
numberOfRowsInSection
section
:
Int
)
->
Int
{
return
10
return
dataSource
.
count
}
}
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
func
tableView
(
_
tableView
:
UITableView
,
cellForRowAt
indexPath
:
IndexPath
)
->
UITableViewCell
{
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
formListCell
,
for
:
indexPath
)
as?
FormListCell
let
cell
=
tableView
.
dequeueReusableCell
(
withIdentifier
:
formListCell
,
for
:
indexPath
)
as?
FormListCell
cell
?
.
outDateLabel
.
text
=
dataSource
[
indexPath
.
row
]
.
outDatetime
cell
?
.
planeDateLabel
.
text
=
dataSource
[
indexPath
.
row
]
.
outDatetime
cell
?
.
createdDateLabel
.
text
=
dataSource
[
indexPath
.
row
]
.
createdAt
return
cell
??
UITableViewCell
()
return
cell
??
UITableViewCell
()
}
}
}
}
...
...
App16/Views/Main/MainViewController.swift
View file @
925add2f
...
@@ -48,7 +48,9 @@ class MainViewController: UIViewController {
...
@@ -48,7 +48,9 @@ class MainViewController: UIViewController {
self
.
openWelcomeController
()
self
.
openWelcomeController
()
}
}
CheckBaseHelper
.
checkBaseResponse
(
baseResposne
,
viewController
:
self
)
CheckBaseHelper
.
checkBaseResponse
(
baseResposne
,
viewController
:
self
)
case
.
success
(
_
):
case
.
success
(
let
response
):
UserDefaultsHelper
.
set
(
alias
:
.
firstName
,
value
:
response
.
firstName
)
UserDefaultsHelper
.
set
(
alias
:
.
lstName
,
value
:
response
.
lastName
)
self
.
openQRController
()
self
.
openQRController
()
case
.
isOffline
:
case
.
isOffline
:
//self.activityIndicator.stopAnimating()
//self.activityIndicator.stopAnimating()
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment