mirror of
https://bitbucket.org/vendoo/vendoo_v1.0.git
synced 2025-12-25 11:47:40 +00:00
Created xml class and xml body
This commit is contained in:
parent
3d2d4822b9
commit
3a9d67399d
@ -45,6 +45,8 @@
|
|||||||
A87525ED0EE7D42D9A7708D8 /* Pods_Vendoo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23ECC3C8465826BD6AC74A02 /* Pods_Vendoo.framework */; };
|
A87525ED0EE7D42D9A7708D8 /* Pods_Vendoo.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 23ECC3C8465826BD6AC74A02 /* Pods_Vendoo.framework */; };
|
||||||
B63CF2871D73CCBF005EA054 /* AmazonRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63CF2861D73CCBF005EA054 /* AmazonRequest.swift */; };
|
B63CF2871D73CCBF005EA054 /* AmazonRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63CF2861D73CCBF005EA054 /* AmazonRequest.swift */; };
|
||||||
B63CF2891D75335A005EA054 /* feedSubmissionTemplate.xml in Resources */ = {isa = PBXBuildFile; fileRef = B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */; };
|
B63CF2891D75335A005EA054 /* feedSubmissionTemplate.xml in Resources */ = {isa = PBXBuildFile; fileRef = B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */; };
|
||||||
|
B63CF28B1D7539B2005EA054 /* AmazonXmlBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63CF28A1D7539B2005EA054 /* AmazonXmlBody.swift */; };
|
||||||
|
B63CF28D1D753A6E005EA054 /* AmazonListing.swift in Sources */ = {isa = PBXBuildFile; fileRef = B63CF28C1D753A6E005EA054 /* AmazonListing.swift */; };
|
||||||
B6FD38131D70EB27008FB41E /* AmazonWebServiceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */; };
|
B6FD38131D70EB27008FB41E /* AmazonWebServiceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */; };
|
||||||
B6FD38151D71CF3E008FB41E /* FeedType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38141D71CF3E008FB41E /* FeedType.swift */; };
|
B6FD38151D71CF3E008FB41E /* FeedType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38141D71CF3E008FB41E /* FeedType.swift */; };
|
||||||
B6FD38171D720540008FB41E /* QuerySigner.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38161D720540008FB41E /* QuerySigner.swift */; };
|
B6FD38171D720540008FB41E /* QuerySigner.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38161D720540008FB41E /* QuerySigner.swift */; };
|
||||||
@ -115,6 +117,8 @@
|
|||||||
A44ED233D6B5454EF92FEB08 /* Pods-Vendoo-VendooUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vendoo-VendooUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vendoo-VendooUITests/Pods-Vendoo-VendooUITests.debug.xcconfig"; sourceTree = "<group>"; };
|
A44ED233D6B5454EF92FEB08 /* Pods-Vendoo-VendooUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Vendoo-VendooUITests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Vendoo-VendooUITests/Pods-Vendoo-VendooUITests.debug.xcconfig"; sourceTree = "<group>"; };
|
||||||
B63CF2861D73CCBF005EA054 /* AmazonRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonRequest.swift; sourceTree = "<group>"; };
|
B63CF2861D73CCBF005EA054 /* AmazonRequest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonRequest.swift; sourceTree = "<group>"; };
|
||||||
B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = feedSubmissionTemplate.xml; sourceTree = "<group>"; };
|
B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = feedSubmissionTemplate.xml; sourceTree = "<group>"; };
|
||||||
|
B63CF28A1D7539B2005EA054 /* AmazonXmlBody.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonXmlBody.swift; sourceTree = "<group>"; };
|
||||||
|
B63CF28C1D753A6E005EA054 /* AmazonListing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonListing.swift; sourceTree = "<group>"; };
|
||||||
B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonWebServiceManager.swift; sourceTree = "<group>"; };
|
B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmazonWebServiceManager.swift; sourceTree = "<group>"; };
|
||||||
B6FD38141D71CF3E008FB41E /* FeedType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedType.swift; sourceTree = "<group>"; };
|
B6FD38141D71CF3E008FB41E /* FeedType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FeedType.swift; sourceTree = "<group>"; };
|
||||||
B6FD38161D720540008FB41E /* QuerySigner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuerySigner.swift; sourceTree = "<group>"; };
|
B6FD38161D720540008FB41E /* QuerySigner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuerySigner.swift; sourceTree = "<group>"; };
|
||||||
@ -351,6 +355,8 @@
|
|||||||
B6FD38161D720540008FB41E /* QuerySigner.swift */,
|
B6FD38161D720540008FB41E /* QuerySigner.swift */,
|
||||||
B63CF2861D73CCBF005EA054 /* AmazonRequest.swift */,
|
B63CF2861D73CCBF005EA054 /* AmazonRequest.swift */,
|
||||||
B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */,
|
B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */,
|
||||||
|
B63CF28A1D7539B2005EA054 /* AmazonXmlBody.swift */,
|
||||||
|
B63CF28C1D753A6E005EA054 /* AmazonListing.swift */,
|
||||||
);
|
);
|
||||||
name = AmazonServices;
|
name = AmazonServices;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@ -780,7 +786,9 @@
|
|||||||
3EA668A11D02836C00EE57A8 /* EbayWebServiceManager.swift in Sources */,
|
3EA668A11D02836C00EE57A8 /* EbayWebServiceManager.swift in Sources */,
|
||||||
3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */,
|
3ECEDB871CF9C722003566B3 /* ListingPreviewViewController.swift in Sources */,
|
||||||
B6FD38151D71CF3E008FB41E /* FeedType.swift in Sources */,
|
B6FD38151D71CF3E008FB41E /* FeedType.swift in Sources */,
|
||||||
|
B63CF28B1D7539B2005EA054 /* AmazonXmlBody.swift in Sources */,
|
||||||
3E1B1F0B1D2493EE00DBCF08 /* EtsySettingsViewController.swift in Sources */,
|
3E1B1F0B1D2493EE00DBCF08 /* EtsySettingsViewController.swift in Sources */,
|
||||||
|
B63CF28D1D753A6E005EA054 /* AmazonListing.swift in Sources */,
|
||||||
3EC325231CF7DA5500626C48 /* HomeViewController.swift in Sources */,
|
3EC325231CF7DA5500626C48 /* HomeViewController.swift in Sources */,
|
||||||
3EC3252D1CF894C400626C48 /* ItemImagePickerViewController.swift in Sources */,
|
3EC3252D1CF894C400626C48 /* ItemImagePickerViewController.swift in Sources */,
|
||||||
3E1DC3CD1D4232490091BC60 /* CategoriesTableViewController.swift in Sources */,
|
3E1DC3CD1D4232490091BC60 /* CategoriesTableViewController.swift in Sources */,
|
||||||
|
|||||||
32
Vendoo/AmazonListing.swift
Normal file
32
Vendoo/AmazonListing.swift
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
//
|
||||||
|
// AmazonListing.swift
|
||||||
|
// Vendoo
|
||||||
|
//
|
||||||
|
// Created by cole alban on 8/29/16.
|
||||||
|
// Copyright © 2016 Okechi Onyeje. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
/*
|
||||||
|
This class will represent a single listing being posted to Amazon
|
||||||
|
*/
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
|
||||||
|
class AmazonListing{
|
||||||
|
|
||||||
|
private var price: Int
|
||||||
|
private var title: String
|
||||||
|
private var quantity: Int
|
||||||
|
private var description: String
|
||||||
|
|
||||||
|
|
||||||
|
//Initalizer, require a price, title, quantity, and description
|
||||||
|
init(price: Int, title: String, quantity: Int, description: String){
|
||||||
|
self.price = price
|
||||||
|
self.title = title
|
||||||
|
self.quantity = quantity
|
||||||
|
self.description = description
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -17,6 +17,19 @@ import Foundation
|
|||||||
*/
|
*/
|
||||||
class AmazonRequest{
|
class AmazonRequest{
|
||||||
|
|
||||||
|
private var listing: AmazonListing
|
||||||
|
private var xmlBody: AmazonXmlBody
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
This constructor will create a request with the given listing and then
|
||||||
|
construct the xml body with the given listing.
|
||||||
|
listing: The listing to create the request from
|
||||||
|
*/
|
||||||
|
init(listing: AmazonListing){
|
||||||
|
self.listing = listing
|
||||||
|
self.xmlBody = AmazonXmlBody(listing)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This helper function will set the headers for the posting a new item to mws
|
This helper function will set the headers for the posting a new item to mws
|
||||||
@ -36,6 +49,16 @@ class AmazonRequest{
|
|||||||
request.addValue("2", forHTTPHeaderField: "SignatureVersion")
|
request.addValue("2", forHTTPHeaderField: "SignatureVersion")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
This will set the body of the request to be the xml body
|
||||||
|
that was created in the constructor.
|
||||||
|
If the xml body is "Error" then nothing will be done as there was an
|
||||||
|
error in the parsing of the body upon creation
|
||||||
|
*/
|
||||||
|
func setRequestBody(){
|
||||||
|
if(self.xmlBody)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This helper function will return an iso8601 formatted datetime string
|
This helper function will return an iso8601 formatted datetime string
|
||||||
return: an iso8601 formatted datetime string
|
return: an iso8601 formatted datetime string
|
||||||
|
|||||||
76
Vendoo/AmazonXmlBody.swift
Normal file
76
Vendoo/AmazonXmlBody.swift
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
//
|
||||||
|
// AmazonXmlBody.swift
|
||||||
|
// Vendoo
|
||||||
|
//
|
||||||
|
// Created by cole alban on 8/29/16.
|
||||||
|
// Copyright © 2016 Okechi Onyeje. All rights reserved.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
/*
|
||||||
|
This class will represent the xml body of an xml feed for Amazon
|
||||||
|
*/
|
||||||
|
class AmazonXmlBody{
|
||||||
|
|
||||||
|
private var listing: AmazonListing
|
||||||
|
private var xmlString: String
|
||||||
|
|
||||||
|
//Init will take in a listing and parse it into the xml string
|
||||||
|
init(listing: AmazonListing){
|
||||||
|
self.listing = listing
|
||||||
|
self.xmlString = parseListing(self.listing)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
This helper function will take in a listing and insert the pertinent
|
||||||
|
information into the respective locations.
|
||||||
|
listing: The listing to parse into the xml string
|
||||||
|
return: The xml string with all pertinent order information
|
||||||
|
*/
|
||||||
|
private func parseListing(listing: AmazonListing)->String{
|
||||||
|
var xmlTemplate = getXmlTemplate()
|
||||||
|
xmlTemplate.replace("{{target}}", replacement: self.listing.title)
|
||||||
|
xmlTemplate.replace("{{description}}", replacement: self.listing.description)
|
||||||
|
xmlTemplate.replace("{{price}}", replacement: self.listing.title)
|
||||||
|
return xmlTemplate
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
This function will get the initial XML template
|
||||||
|
return: String representing the xml template
|
||||||
|
*/
|
||||||
|
private func getXmlTemplate()->String{
|
||||||
|
var xmlString: String
|
||||||
|
let manager = NSFileManager.defaultManager()
|
||||||
|
let path = manager.currentDirectoryPath+"/feedSubmissionTemplate.xml"
|
||||||
|
do{
|
||||||
|
xmlString = try{
|
||||||
|
NSString(contentsOfURL: path, encoding: String.encoding.utf8.rawValue) as String
|
||||||
|
}
|
||||||
|
return xmlString
|
||||||
|
}
|
||||||
|
catch{
|
||||||
|
return "Error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//A small extension to give string a replace function with persistence
|
||||||
|
extenstion String{
|
||||||
|
|
||||||
|
/*
|
||||||
|
Replaces target with replacement in the string instance.
|
||||||
|
Target: The string to replace
|
||||||
|
replacement: The new string to insert
|
||||||
|
return: the new string with the replaced snippet
|
||||||
|
*/
|
||||||
|
func replace(target: String, replacement: String)->String{
|
||||||
|
self = self.stringByReplacingOccurrencesOfString(target, withString: replacement)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -18,13 +18,13 @@
|
|||||||
</StandardProductID>
|
</StandardProductID>
|
||||||
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
|
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
|
||||||
<DescriptionData>
|
<DescriptionData>
|
||||||
<Title>Example Product Title</Title>
|
<Title>{{title}}</Title>
|
||||||
<Brand>Example Product Brand</Brand>
|
<Brand>Vendoo</Brand>
|
||||||
<Description>This is an example product description.</Description>
|
<Description>{{description}}</Description>
|
||||||
<BulletPoint>Example Bullet Point 1</BulletPoint>
|
<BulletPoint>Example Bullet Point 1</BulletPoint>
|
||||||
<BulletPoint>Example Bullet Point 2</BulletPoint>
|
<BulletPoint>Example Bullet Point 2</BulletPoint>
|
||||||
<MSRP currency="USD">25.19</MSRP>
|
<MSRP currency="USD">{{price}}</MSRP>
|
||||||
<Manufacturer>Example Product Manufacturer</Manufacturer>
|
<Manufacturer>Kroleo</Manufacturer>
|
||||||
<ItemType>example-item-type</ItemType>
|
<ItemType>example-item-type</ItemType>
|
||||||
</DescriptionData>
|
</DescriptionData>
|
||||||
<ProductData>
|
<ProductData>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user