mirror of
https://bitbucket.org/vendoo/vendoo_v1.0.git
synced 2025-12-25 11:47:40 +00:00
Add feed submission xml template and finish query string creation
This commit is contained in:
parent
e65ddf71d3
commit
3d2d4822b9
3
Podfile
3
Podfile
@ -29,8 +29,7 @@ use_frameworks!
|
||||
pod 'TYMActivityIndicatorView'
|
||||
pod 'BSImagePicker', '~> 2.3'
|
||||
pod 'SWRevealViewController'
|
||||
# pod 'CommonCrypto'
|
||||
#'~> 1.1'
|
||||
pod 'CommonCrypto'
|
||||
|
||||
target 'VendooTests' do
|
||||
# inherit! :search_paths
|
||||
|
||||
@ -43,6 +43,8 @@
|
||||
3EFB0E331D0B968300A05D7A /* SideMenuView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3EFB0E321D0B968300A05D7A /* SideMenuView.swift */; };
|
||||
3F8E0464700649BDD8B552B1 /* Pods_Vendoo_VendooTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B876489113F498AF1D2FD7E9 /* Pods_Vendoo_VendooTests.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 */; };
|
||||
B63CF2891D75335A005EA054 /* feedSubmissionTemplate.xml in Resources */ = {isa = PBXBuildFile; fileRef = B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */; };
|
||||
B6FD38131D70EB27008FB41E /* AmazonWebServiceManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */; };
|
||||
B6FD38151D71CF3E008FB41E /* FeedType.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38141D71CF3E008FB41E /* FeedType.swift */; };
|
||||
B6FD38171D720540008FB41E /* QuerySigner.swift in Sources */ = {isa = PBXBuildFile; fileRef = B6FD38161D720540008FB41E /* QuerySigner.swift */; };
|
||||
@ -111,6 +113,8 @@
|
||||
3EFB0E321D0B968300A05D7A /* SideMenuView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SideMenuView.swift; sourceTree = "<group>"; };
|
||||
7D1FC6F6278B48A7BA9A9E03 /* Pods_Vendoo_VendooUITests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Vendoo_VendooUITests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
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>"; };
|
||||
B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = feedSubmissionTemplate.xml; 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>"; };
|
||||
B6FD38161D720540008FB41E /* QuerySigner.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = QuerySigner.swift; sourceTree = "<group>"; };
|
||||
@ -345,6 +349,8 @@
|
||||
B6FD38121D70EB27008FB41E /* AmazonWebServiceManager.swift */,
|
||||
B6FD38141D71CF3E008FB41E /* FeedType.swift */,
|
||||
B6FD38161D720540008FB41E /* QuerySigner.swift */,
|
||||
B63CF2861D73CCBF005EA054 /* AmazonRequest.swift */,
|
||||
B63CF2881D75335A005EA054 /* feedSubmissionTemplate.xml */,
|
||||
);
|
||||
name = AmazonServices;
|
||||
sourceTree = "<group>";
|
||||
@ -488,6 +494,7 @@
|
||||
3E7CF3FE1CF5FF8200F486B2 /* GoogleService-Info.plist in Resources */,
|
||||
3E1AA4301D0D9B3F005FCCBB /* Main.storyboard in Resources */,
|
||||
3E6CC3601CF2A94B00E00A70 /* Assets.xcassets in Resources */,
|
||||
B63CF2891D75335A005EA054 /* feedSubmissionTemplate.xml in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -764,6 +771,7 @@
|
||||
B6FD38171D720540008FB41E /* QuerySigner.swift in Sources */,
|
||||
3EC3251E1CF734C100626C48 /* NetworksTableViewController.swift in Sources */,
|
||||
3EC325201CF7C3AB00626C48 /* NetworkTableViewCell.swift in Sources */,
|
||||
B63CF2871D73CCBF005EA054 /* AmazonRequest.swift in Sources */,
|
||||
3EC325261CF7E90000626C48 /* FacebookGraphAPIManager.swift in Sources */,
|
||||
B6FD38131D70EB27008FB41E /* AmazonWebServiceManager.swift in Sources */,
|
||||
3E7CF3FC1CF5FE9400F486B2 /* RecoverPasswordViewController.swift in Sources */,
|
||||
@ -837,6 +845,7 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
@ -887,6 +896,7 @@
|
||||
CLANG_CXX_LIBRARY = "libc++";
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||
CLANG_WARN_BOOL_CONVERSION = YES;
|
||||
CLANG_WARN_CONSTANT_CONVERSION = YES;
|
||||
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
|
||||
|
||||
69
Vendoo/AmazonRequest.swift
Normal file
69
Vendoo/AmazonRequest.swift
Normal file
@ -0,0 +1,69 @@
|
||||
//
|
||||
// AmazonRequest.swift
|
||||
// Vendoo
|
||||
//
|
||||
// Created by cole alban on 8/28/16.
|
||||
// Copyright © 2016 Okechi Onyeje. All rights reserved.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/*
|
||||
This class will represent a request to the Amazon MWS API.
|
||||
It will contain methods for creating headers, getting the
|
||||
headers back as a queryString(used to sign the request), and
|
||||
metadata regarding the transaction.
|
||||
*/
|
||||
class AmazonRequest{
|
||||
|
||||
|
||||
/*
|
||||
This helper function will set the headers for the posting a new item to mws
|
||||
request: The request headers will be set for
|
||||
feedType: The type of feed this request will be for
|
||||
*/
|
||||
func setRequestHeaders(request: NSMutableURLRequest, feedType: FeedType ){
|
||||
request.HTTPMethod = "POST"
|
||||
request.addValue("text/xml", forHTTPHeaderField: "Content-Type")
|
||||
request.addValue("SubmitFeed", forHTTPHeaderField: "Action")
|
||||
request.addValue(self.awsAccessKeyId, forHTTPHeaderField: "AWSAccessKeyId")
|
||||
request.addValue(self.sellerId, forHTTPHeaderField: "Merchant")
|
||||
request.addValue(getIso8601DateTimeString(), forHTTPHeaderField: "Timestamp")
|
||||
request.addValue("2009-01-01", forHTTPHeaderField: "Version")
|
||||
request.addValue(feedType.rawValue, forHTTPHeaderField: "FeedType")
|
||||
request.addValue("HmacSHA256", forHTTPHeaderField: "SignatureMethod")
|
||||
request.addValue("2", forHTTPHeaderField: "SignatureVersion")
|
||||
}
|
||||
|
||||
/*
|
||||
This helper function will return an iso8601 formatted datetime string
|
||||
return: an iso8601 formatted datetime string
|
||||
*/
|
||||
func getIso8601DateTimeString()->String{
|
||||
let dateFormatter: NSDateFormatter = NSDateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
|
||||
dateFormatter.timeZone = NSTimeZone(forSecondsFromGMT: 0)
|
||||
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
|
||||
return dateFormatter.stringFromDate(NSDate())
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This will return a properly formatted header in string form
|
||||
Note: This is before the query is signed.
|
||||
*/
|
||||
func getRequestHeaderAsString(request: NSMutableURLRequest)->String{
|
||||
var queryString: String = "POST\nmws.amazonservices.com\n\\"+
|
||||
queryString += "AwsAccessKeyId="+request.valueForHTTPHeaderField("AwsAccessKeyId")
|
||||
queryString += "&Action="+request.valueForHTTPHeaderField("Action")
|
||||
queryString += "&FeedType="+request.valueForHTTPHeaderField("FeedType")
|
||||
queryString += "&SellerId="+request.valueForHTTPHeaderField("SellerId")
|
||||
queryString += "&SignatureMethod="+request.valueForHTTPHeaderField("SignatureMethod")
|
||||
queryString += "&SignatureVersion="+request.valueForHTTPHeaderField("SignatureVersion")
|
||||
queryString += "&Timestamp="+request.valueForHTTPHeaderField("Timestamp")
|
||||
queryString += "&Version="+request.valueForHTTPHeaderField("Version")
|
||||
return queryString
|
||||
}
|
||||
|
||||
}
|
||||
@ -23,6 +23,7 @@ class AmazonWebServiceManager{
|
||||
private var awsAccessKeyId: String
|
||||
private var secretKey: String
|
||||
private var developerAccountNumber: String
|
||||
private var mwsApiEndpoint: String
|
||||
|
||||
/*
|
||||
These values are currently hardcoded in and map to the Kroleo
|
||||
@ -36,6 +37,7 @@ class AmazonWebServiceManager{
|
||||
self.awsAccessKeyId = "AKIAJL6QFNV3AHMJMBRA"
|
||||
self.secretKey = "kFqZDTBm/ZReefYKBZTVZ17DSwmRHXhINpizk655"
|
||||
self.developerAccountNumber = "6187-7922-4188"
|
||||
self.mwsApiEndpoint = "https://mws.amazonservices.com"
|
||||
}
|
||||
|
||||
/*
|
||||
@ -43,40 +45,12 @@ class AmazonWebServiceManager{
|
||||
params: Hash of information used to post an item to amazon
|
||||
*/
|
||||
func listItem(params: [String: AnyObject]){
|
||||
let mwsApiEndpointUrl: NSURL = NSURL(fileURLWithPath: "https://mws.amazonservices.com")
|
||||
let amazonMWSRequest: NSMutableURLRequest = NSMutableURLRequest(URL: mwsApiEndpointUrl)
|
||||
let mwsApiEndpointUrl = NSURL(fileURLWithPath: mwsApiEndpointUrl)
|
||||
let amazonMWSRequest = NSMutableURLRequest(URL: mwsApiEndpointUrl)
|
||||
setRequestHeaders(amazonMWSRequest, feedType: FeedType.POST_PRODUCT_DATA)
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This helper function will set the headers for the posting a new item to mws
|
||||
request: The request headers will be set for
|
||||
feedType: The type of feed this request will be for
|
||||
*/
|
||||
private func setRequestHeaders(request: NSMutableURLRequest, feedType: FeedType ){
|
||||
request.HTTPMethod = "POST"
|
||||
request.addValue("SubmitFeed", forHTTPHeaderField: "Action")
|
||||
request.addValue(self.awsAccessKeyId, forHTTPHeaderField: "AWSAccessKeyId")
|
||||
request.addValue(self.sellerId, forHTTPHeaderField: "Merchant")
|
||||
request.addValue(getIso8601DateTimeString(), forHTTPHeaderField: "Timestamp")
|
||||
request.addValue("2009-01-01", forHTTPHeaderField: "Version")
|
||||
request.addValue(feedType.rawValue, forHTTPHeaderField: "FeedType")
|
||||
request.addValue("HmacSHA256", forHTTPHeaderField: "SignatureMethod")
|
||||
request.addValue("2", forHTTPHeaderField: "SignatureVersion")
|
||||
}
|
||||
|
||||
/*
|
||||
This helper function will return an iso8601 formatted datetime string
|
||||
return: an iso8601 formatted datetime string
|
||||
*/
|
||||
private func getIso8601DateTimeString()->String{
|
||||
let dateFormatter: NSDateFormatter = NSDateFormatter()
|
||||
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
|
||||
dateFormatter.timeZone = NSTimeZone(forSecondsFromGMT: 0)
|
||||
dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX")
|
||||
return dateFormatter.stringFromDate(NSDate())
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -19,10 +19,12 @@ enum FeedType: String{
|
||||
case POST_FLAT_FILE_INVLOADER_DATA = "_POST_FLAT_FILE_INVLOADER_DATA_"
|
||||
case POST_FLAT_FILE_LISTINGS_DATA = "_POST_FLAT_FILE_LISTINGS_DATA_"
|
||||
case POST_FLAT_FILE_BOOKLOADER_DATA = "_POST_FLAT_FILE_BOOKLOADER_DATA_"
|
||||
case POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA = "_POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA_"
|
||||
case POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA = "_POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA_"
|
||||
case POST_UIEE_BOOKLOADER_DATA = " _POST_UIEE_BOOKLOADER_DATA_"
|
||||
case POST_STD_ACES_DATA = "_POST_STD_ACES_DATA_"
|
||||
case POST_FLAT_FILE_CONVERGENCE_LISTINGS_DATA = "_POST_FLAT_FILE_CONVERGENCE"+
|
||||
"_LISTINGS_DATA_"
|
||||
case POST_FLAT_FILE_PRICEANDQUANTITYONLY_UPDATE_DATA = "_POST_FLAT_FILE_PRIC"+
|
||||
"EANDQUANTITYONLY_UPDATE_DATA_"
|
||||
|
||||
|
||||
}
|
||||
42
Vendoo/feedSubmissionTemplate.xml
Normal file
42
Vendoo/feedSubmissionTemplate.xml
Normal file
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<AmazonEnvelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:noNamespaceSchemaLocation="amzn-envelope.xsd">
|
||||
<Header>
|
||||
<DocumentVersion>1.01</DocumentVersion>
|
||||
<MerchantIdentifier>M_EXAMPLE_123456</MerchantIdentifier>
|
||||
</Header>
|
||||
<MessageType>Product</MessageType>
|
||||
<PurgeAndReplace>false</PurgeAndReplace>
|
||||
<Message>
|
||||
<MessageID>1</MessageID>
|
||||
<OperationType>Update</OperationType>
|
||||
<Product>
|
||||
<SKU>56789</SKU>
|
||||
<StandardProductID>
|
||||
<Type>ASIN</Type>
|
||||
<Value>B0EXAMPLEG</Value>
|
||||
</StandardProductID>
|
||||
<ProductTaxCode>A_GEN_NOTAX</ProductTaxCode>
|
||||
<DescriptionData>
|
||||
<Title>Example Product Title</Title>
|
||||
<Brand>Example Product Brand</Brand>
|
||||
<Description>This is an example product description.</Description>
|
||||
<BulletPoint>Example Bullet Point 1</BulletPoint>
|
||||
<BulletPoint>Example Bullet Point 2</BulletPoint>
|
||||
<MSRP currency="USD">25.19</MSRP>
|
||||
<Manufacturer>Example Product Manufacturer</Manufacturer>
|
||||
<ItemType>example-item-type</ItemType>
|
||||
</DescriptionData>
|
||||
<ProductData>
|
||||
<Health>
|
||||
<ProductType>
|
||||
<HealthMisc>
|
||||
<Ingredients>Example Ingredients</Ingredients>
|
||||
<Directions>Example Directions</Directions>
|
||||
</HealthMisc>
|
||||
</ProductType>
|
||||
</Health>
|
||||
</ProductData>
|
||||
</Product>
|
||||
</Message>
|
||||
</AmazonEnvelope>
|
||||
Loading…
x
Reference in New Issue
Block a user