Skip to content

Commit

Permalink
Added semnaleaza contract and other visual fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
silviu committed Jun 7, 2018
1 parent c25124b commit 8d57424
Show file tree
Hide file tree
Showing 34 changed files with 405 additions and 65 deletions.
111 changes: 92 additions & 19 deletions harta-banilor-publici/ApiHelper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,40 @@ struct InstitutionLicitatie: Codable {
}
}

struct SearchResultLicitatie: Codable {
let id: Int
let titluContract: String
let valoareRON: String
let dataContract: String

private enum CodingKeys: String, CodingKey {
case id = "LicitatieId", dataContract = "DataContract"
case titluContract = "TitluContract", valoareRON = "ValoareRON"
}
}

struct SearchResultContract: Codable {
let id: Int
let titluContract: String
let valoareRON: String
let dataContract: String

private enum CodingKeys: String, CodingKey {
case id = "ContracteId", dataContract = "DataContract"
case titluContract = "TitluContract", valoareRON = "ValoareRON"
}
}


struct Contract: Codable {
let id, institutiePublicaID, companieId: Int
let id, institutiePublicaID, companieId, numarJustificari: Int
let companieCUI, tipProcedura, institutiePublicaCUI, numarAnuntParticipare: String
let dataAnuntParticipare, tipIncheiereContract, numarContract, dataContract: String
let titluContract, cpvCode: String
let valoareRON, valoareEUR: String

private enum CodingKeys: String, CodingKey {
case id = "ContracteId", institutiePublicaID = "InstitutiePublicaID", companieId = "CompanieId"
case id = "ContracteId", institutiePublicaID = "InstitutiePublicaID", companieId = "CompanieId", numarJustificari = "NumarJustificari"
case companieCUI = "CompanieCUI", tipProcedura = "TipProcedura", institutiePublicaCUI = "InstitutiePublicaCUI"
case numarAnuntParticipare = "NumarAnuntParticipare", dataAnuntParticipare = "DataAnuntParticipare"
case tipIncheiereContract = "TipIncheiereContract", numarContract = "NumarContract", dataContract = "DataContract"
Expand All @@ -59,22 +84,23 @@ struct Contract: Codable {
}

struct Licitatie: Codable {
let id, institutiePublicaID: Int
let id, institutiePublicaID, companieId, numarOfertePrimite, cpvCodeID, numarJustificari: Int
let companieCUI, tip, tipContract, tipProcedura, institutiePublicaCUI, tipActivitateAC, numarAnuntAtribuire: String
let dataAnuntAtribuire, tipIncheiereContract, tipCriteriiAtribuire, CUILicitatieElectronica, numarOfertePrimite: String
let subcontractat, numarContract, dataContract: String
let titluContract, cpvCodeID, cpvCode, numarAnuntParticipare, dataAnuntParticipare: String
let dataAnuntAtribuire, tipIncheiereContract, tipCriteriiAtribuire: String
let numarContract, dataContract: String
let titluContract, cpvCode, numarAnuntParticipare, dataAnuntParticipare: String
let valoareEstimataParticipare, monedaValoareEstimataParticipare, depoziteGarantii, modalitatiFinantare: String
let valoareRON, valoareEUR: String
let CUILicitatieElectronica, subcontractat: Bool

private enum CodingKeys: String, CodingKey {
case id = "LicitatiiId", institutiePublicaID = "InstitutiePublicaID"
case companieCUI = "CompanieCUI", tip = "Tip", tipContract = "TipContract", tipProcedura = "TipProcedura"
case id = "LicitatiiId", institutiePublicaID = "InstitutiePublicaID", companieId = "CompanieId", numarOfertePrimite = "NumarOfertePrimite"
case companieCUI = "CompanieCUI", tip = "Tip", tipContract = "TipContract", tipProcedura = "TipProcedura", numarJustificari = "NumarJustificari"
case institutiePublicaCUI = "InstitutiePublicaCUI", tipActivitateAC = "TipActivitateAC", numarAnuntAtribuire = "NumarAnuntAtribuire"
case dataAnuntAtribuire = "DataAnuntAtribuire", tipIncheiereContract = "TipIncheiereContract", tipCriteriiAtribuire = "TipCriteriiAtribuire"
case CUILicitatieElectronica = "CUILicitatieElectronica", numarOfertePrimite = "NumarOfertePrimite", subcontractat = "Subcontractat"
case CUILicitatieElectronica = "CUILicitatieElectronica", subcontractat = "Subcontractat"
case numarContract = "NumarContract", dataContract = "DataContract", titluContract = "TitluContract", valoareRON = "ValoareRON"
case valoareEUR = "ValoareEUR", cpvCodeID = "CPVCodeID", cpvCode = "CPVCode", numarAnuntParticipare = "NumarAnuntParticipare"
case valoareEUR = "ValoareEUR", cpvCodeID = "CPVCodeId", cpvCode = "CPVCode", numarAnuntParticipare = "NumarAnuntParticipare"
case dataAnuntParticipare = "DataAnuntParticipare", valoareEstimataParticipare = "ValoareEstimataParticipare"
case monedaValoareEstimataParticipare = "MonedaValoareEstimataParticipare", depoziteGarantii = "DepoziteGarantii", modalitatiFinantare = "ModalitatiFinantare"
}
Expand Down Expand Up @@ -607,9 +633,9 @@ class ApiHelper {
}


func searchContracts(pattern: String, handler: @escaping ([InstitutionContract], URLResponse?, Error?) -> Void) {
var contractResults: [InstitutionContract] = []
let url = self.apiURL + "SearchContract/" + pattern.folding(options: .diacriticInsensitive, locale: .current).trimmingCharacters(in: .whitespacesAndNewlines).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
func searchContracts(pattern: String, handler: @escaping ([SearchResultContract], URLResponse?, Error?) -> Void) {
var contractResults: [SearchResultContract] = []
let url = self.apiURL + "SearchAD/" + pattern.folding(options: .diacriticInsensitive, locale: .current).trimmingCharacters(in: .whitespacesAndNewlines).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
print("Searching Contracts: " + url)

let task = URLSession.shared.dataTask(with: URL(string: url)!) { data, response, error in
Expand All @@ -622,7 +648,7 @@ class ApiHelper {
return
}
do {
contractResults = try JSONDecoder().decode([InstitutionContract].self, from: data)
contractResults = try JSONDecoder().decode([SearchResultContract].self, from: data)
handler(contractResults, response, error)
} catch let error {
print("json error: \(error)")
Expand All @@ -632,12 +658,12 @@ class ApiHelper {
task.resume()
}

func searchLicitatii(pattern: String, handler: @escaping ([InstitutionLicitatie], URLResponse?, Error?) -> Void) {
var licitatieResults: [InstitutionLicitatie] = []
func searchLicitatii(pattern: String, handler: @escaping ([SearchResultLicitatie], URLResponse?, Error?) -> Void) {
var licitatieResults: [SearchResultLicitatie] = []

let url = self.apiURL + "SearchTenters/" + pattern.folding(options: .diacriticInsensitive, locale: .current).trimmingCharacters(in: .whitespacesAndNewlines).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
let url = self.apiURL + "SearchTender/" + pattern.folding(options: .diacriticInsensitive, locale: .current).trimmingCharacters(in: .whitespacesAndNewlines).addingPercentEncoding(withAllowedCharacters: CharacterSet.urlQueryAllowed)!
print("Searching Licitatii for " + url)

let task = URLSession.shared.dataTask(with: URL(string: url)!) { data, response, error in
guard error == nil else {
handler(licitatieResults, response, error)
Expand All @@ -648,7 +674,7 @@ class ApiHelper {
return
}
do {
licitatieResults = try JSONDecoder().decode([InstitutionLicitatie].self, from: data)
licitatieResults = try JSONDecoder().decode([SearchResultLicitatie].self, from: data)
handler(licitatieResults, response, error)
} catch let error {
print("json error: \(error)")
Expand All @@ -657,4 +683,51 @@ class ApiHelper {
}
task.resume()
}

func semnaleazaAD(contractId: Int) {
let url = self.apiURL + "JustifyAD/" + String(contractId)
print("Semnaleaza AD " + url)

var request = URLRequest(url: URL(string: url)!)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"


let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard error == nil else {
print("error=\(String(describing: error))")
return
}

if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(String(describing: response))")
}

}
task.resume()
}

func semnaleazaTender(tenderId: Int) {
let url = self.apiURL + "JustifyTender/" + String(tenderId)
print("Semnaleaza AD " + url)

var request = URLRequest(url: URL(string: url)!)
request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
request.httpMethod = "POST"


let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard error == nil else {
print("error=\(String(describing: error))")
return
}

if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {
print("statusCode should be 200, but is \(httpStatus.statusCode)")
print("response = \(String(describing: response))")
}
}
task.resume()
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "search.png",
"filename" : "ic_info_outline_black.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "search@2x.png",
"filename" : "ic_info_outline_black@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "search@3x.png",
"filename" : "ic_info_outline_black@3x.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "barchart.png",
"filename" : "ic_map_black.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "barchart@2x.png",
"filename" : "ic_map_black@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "barchart@3x.png",
"filename" : "ic_map_black@3x.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "info.png",
"filename" : "ic_search_black.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "info@2x.png",
"filename" : "ic_search_black@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "info@3x.png",
"filename" : "ic_search_black@3x.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"images" : [
{
"idiom" : "universal",
"filename" : "placeholder.png",
"filename" : "ic_show_chart_black.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "placeholder@2x.png",
"filename" : "ic_show_chart_black@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "placeholder@3x.png",
"filename" : "ic_show_chart_black@3x.png",
"scale" : "3x"
}
],
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 8d57424

Please sign in to comment.