Commit 522bcc3c authored by Bosko Petreski's avatar Bosko Petreski Committed by Bosko Petreski

new documentation spec API changes

parent 4ec8c6d0
......@@ -8,6 +8,10 @@
/* Begin PBXBuildFile section */
580747882A1BDB33247F36EC9CF6AAF7 /* Pods-PrimedIO_Tests-umbrella.h in Headers */ = {isa = PBXBuildFile; fileRef = 7F3C4065187073CAA15269D33F1BE910 /* Pods-PrimedIO_Tests-umbrella.h */; settings = {ATTRIBUTES = (Public, ); }; };
6D5D48C72105FBB000C5160D /* PrimedTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D5D48C52105FBB000C5160D /* PrimedTracker.h */; };
6D5D48C82105FBB000C5160D /* PrimedTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D5D48C62105FBB000C5160D /* PrimedTracker.m */; };
6D5D48C92105FBB600C5160D /* PrimedTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 6D5D48C62105FBB000C5160D /* PrimedTracker.m */; };
6D5D48CA2105FBBC00C5160D /* PrimedTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = 6D5D48C52105FBB000C5160D /* PrimedTracker.h */; };
6DCE261520F4E45000CA1E3B /* PrimedIO.h in Headers */ = {isa = PBXBuildFile; fileRef = E9051E8431F1C3ACAD68326D7B95C854 /* PrimedIO.h */; };
6DCE261620F4E45300CA1E3B /* PrimedIO.m in Sources */ = {isa = PBXBuildFile; fileRef = 47FFE7C1A05CC5BD011091E2C71060A0 /* PrimedIO.m */; };
B59C86CF4437AEF0779E141899DF6299 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A16F4CFC63FAC439D7A04994F579A03 /* Foundation.framework */; };
......@@ -60,6 +64,8 @@
621A938CE86A879D4CD124E2AD48A9E9 /* Info.plist */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
626322298947A33E2244107ADCD836B7 /* Pods-PrimedIO_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = "Pods-PrimedIO_Example.release.xcconfig"; sourceTree = "<group>"; };
6CC622BA08B1B9B8A484C7BE3D47D6DB /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
6D5D48C52105FBB000C5160D /* PrimedTracker.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = PrimedTracker.h; path = PrimedIO/Classes/PrimedTracker.h; sourceTree = "<group>"; };
6D5D48C62105FBB000C5160D /* PrimedTracker.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = PrimedTracker.m; path = PrimedIO/Classes/PrimedTracker.m; sourceTree = "<group>"; };
6FD0DD146064862D013E5FE354760BD5 /* PrimedIO.modulemap */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.module; path = PrimedIO.modulemap; sourceTree = "<group>"; };
77A40DD6123DA6713E3F7CECF0223ED4 /* PrimedIO.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; path = PrimedIO.xcconfig; sourceTree = "<group>"; };
7D51FE121A18A375DB278E0B0590F3B1 /* PrimedIO.podspec */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; includeInIndex = 1; path = PrimedIO.podspec; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.ruby; };
......@@ -215,6 +221,8 @@
children = (
E9051E8431F1C3ACAD68326D7B95C854 /* PrimedIO.h */,
47FFE7C1A05CC5BD011091E2C71060A0 /* PrimedIO.m */,
6D5D48C52105FBB000C5160D /* PrimedTracker.h */,
6D5D48C62105FBB000C5160D /* PrimedTracker.m */,
FAD35164081AC6232CC1ED27D79D7269 /* Pod */,
789EEC28A61C1260E0CDF47CEC9F5C8A /* Support Files */,
);
......@@ -239,6 +247,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
6D5D48CA2105FBBC00C5160D /* PrimedTracker.h in Headers */,
C7AF227B2E1EADEEB7AF8A70E617D5C7 /* PrimedIO-umbrella.h in Headers */,
EE87EB70654957E4C0FB6023ED9EE213 /* PrimedIO.h in Headers */,
);
......@@ -256,6 +265,7 @@
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
6D5D48C72105FBB000C5160D /* PrimedTracker.h in Headers */,
C92D2105F03A0FF1C282671B5A59D056 /* Pods-PrimedIO_Example-umbrella.h in Headers */,
6DCE261520F4E45000CA1E3B /* PrimedIO.h in Headers */,
);
......@@ -350,6 +360,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6D5D48C92105FBB600C5160D /* PrimedTracker.m in Sources */,
B79C923C270F53DBE88E180358B53609 /* PrimedIO-dummy.m in Sources */,
BF0F83BAAB80AF21B1D975AF163968BC /* PrimedIO.m in Sources */,
);
......@@ -367,6 +378,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
6D5D48C82105FBB000C5160D /* PrimedTracker.m in Sources */,
6DCE261620F4E45300CA1E3B /* PrimedIO.m in Sources */,
F12D55FC10915DE95FFF87AB206791F5 /* Pods-PrimedIO_Example-dummy.m in Sources */,
);
......
......@@ -21,13 +21,13 @@
// Do any additional setup after loading the view, typically from a nib.
// Create Instance
PrimedIO *primed = [[PrimedIO alloc] initWithPublicKey:@"somekey" secretKey:@"somesecretkeywithalotofchars" url:@"API_URL_GO_HERE"];
PrimedIO *primed = [[PrimedIO alloc] initWithPublicKey:@"somekey" secretKey:@"somesecretkeywithalotofchars" connectionString:@"API_URL_GO_HERE"];
NSDictionary *dictSignals = @{@"device": @"iphone",
@"userid": @"someuserid"
};
[primed personalise:@"frontpage.article.bottom" signals:dictSignals limit:3 success:^(NSDictionary *response) {
[primed personalise:@"frontpage.article.bottom" signals:dictSignals limit:3 abvariantLabel:@"A" success:^(NSDictionary *response) {
//Handle response
NSLog(@"personalise: %@",response);
} failed:^(NSString *message) {
......
......@@ -40,7 +40,7 @@
NSString *private_key = @"this_is_also_fake";
NSString *prepSignature = [NSString stringWithFormat:@"%@%@%@",public_key,private_key,nonce];
NSString *sha512Signature = [PrimedIO createSHA512:prepSignature];
NSString *sha512Signature = [PrimedIO hmac:prepSignature];
NSString *sha512Expect = @"71c500ca5a6b22c805da2885c4b9ea795b0a6b57369917b9c7814f6d679aeb40c1cca6d965f9a0cf621eb0d02997ea3c5bb5e908c61b257e60f0442bf37eb3e5";
......
......@@ -19,10 +19,10 @@ typedef void(^APIFailed)(NSString *message);
* Create instance of PrimedIO class
* @param publicKey Public Key provided by PrimedIO
* @param secretKey Secret Key provided by PrimedIO
* @param url URL to API for PrimedIO service
* @param connectionString URL to API for PrimedIO service
* @return PrimedIO instance
*/
-(PrimedIO *)initWithPublicKey:(NSString *)publicKey secretKey:(NSString *)secretKey url:(NSString *)url;
-(PrimedIO *)initWithPublicKey:(NSString *)publicKey secretKey:(NSString *)secretKey connectionString:(NSString *)connectionString;
/**
* Deal with the results as they are returned
......@@ -30,7 +30,7 @@ typedef void(^APIFailed)(NSString *message);
* @param signals Dictionary signals
* @param limit Limit the response
*/
-(void)personalise:(NSString *)campaign signals:(NSDictionary *)signals limit:(NSUInteger)limit success:(APISuccess)success failed:(APIFailed)failed;
-(void)personalise:(NSString *)campaign signals:(NSDictionary *)signals limit:(NSUInteger)limit abvariantLabel:(NSString *)abvariantLabel success:(APISuccess)success failed:(APIFailed)failed;
/**
* Converting clicks.
......@@ -51,6 +51,6 @@ typedef void(^APIFailed)(NSString *message);
*/
-(void)convert:(NSString *)ruuid data:(NSDictionary *)data;
+(NSString *)createSHA512:(NSString *)string;
+(NSString *)hmac:(NSString *)string;
@end
......@@ -15,12 +15,12 @@
NSString *sha512Signature;
NSString *public_key;
NSString *nonce;
NSString *urlPrimedIO;
NSString *connectionStringPrimedIO;
}
#pragma mark - HTTP Methods
-(NSMutableURLRequest *)requestWithURL:(NSString *)urlLink method:(NSString *)method{
NSString *strUrl = [NSString stringWithFormat:@"%@%@",urlPrimedIO,urlLink];
NSString *strUrl = [NSString stringWithFormat:@"%@%@",connectionStringPrimedIO,urlLink];
NSURL *URL = [NSURL URLWithString:strUrl];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:URL];
......@@ -97,7 +97,7 @@
}
#pragma mark - CustomFunctions
+(NSString *)createSHA512:(NSString *)string{
+(NSString *)hmac:(NSString *)string{
const char *cstr = [string cStringUsingEncoding:NSUTF8StringEncoding];
NSData *data = [NSData dataWithBytes:cstr length:string.length];
uint8_t digest[CC_SHA512_DIGEST_LENGTH];
......@@ -110,20 +110,20 @@
}
#pragma mark - Initialization
-(PrimedIO *)initWithPublicKey:(NSString *)publicKey secretKey:(NSString *)secretKey url:(NSString *)url{
-(PrimedIO *)initWithPublicKey:(NSString *)publicKey secretKey:(NSString *)secretKey connectionString:(NSString *)connectionString{
if ((self = [super init])){
if(self.debug){ PrimedIOLog(@"Primed Debug Activated") }
public_key = publicKey;
nonce = [NSString stringWithFormat:@"%.f",NSDate.date.timeIntervalSince1970];
NSString *prepSignature = [NSString stringWithFormat:@"%@%@%@",publicKey,secretKey,nonce];
sha512Signature = [PrimedIO createSHA512:prepSignature];
urlPrimedIO = url;
sha512Signature = [PrimedIO hmac:prepSignature];
connectionStringPrimedIO = connectionString;
}
return self;
}
#pragma mark - API Main Functions
-(void)personalise:(NSString *)campaign signals:(NSDictionary *)signals limit:(NSUInteger)limit success:(APISuccess)success failed:(APIFailed)failed{
-(void)personalise:(NSString *)campaign signals:(NSDictionary *)signals limit:(NSUInteger)limit abvariantLabel:(NSString *)abvariantLabel success:(APISuccess)success failed:(APIFailed)failed;{
NSError *errorJSON;
NSData *signalsJSON = [NSJSONSerialization dataWithJSONObject:signals options:0 error:&errorJSON];
......@@ -137,6 +137,7 @@
NSMutableString *generateURL = [NSMutableString stringWithString:@"/api/v1/personalise?"];
[generateURL appendFormat:@"campaign=%@",campaign];
[generateURL appendFormat:@"&limit=%lu",(unsigned long)limit];
[generateURL appendFormat:@"&abvariantLabel=%@",[abvariantLabel stringByAddingPercentEncodingWithAllowedCharacters:setEncoding]];
[generateURL appendFormat:@"&signals=%@",[signalToString stringByAddingPercentEncodingWithAllowedCharacters:setEncoding]];
[self get:generateURL success:^(NSDictionary *response) {
......
//
// PrimedTracker.h
// Pods-PrimedIO_Example
//
// Created by Bosko Petreski on 7/23/18.
//
#import <Foundation/Foundation.h>
#import "PrimedIO.h"
@interface PrimedTracker : PrimedIO
/**
* Create instance of PrimedTracker class
* @param publicKey Public Key provided by PrimedIO
* @param secretKey Secret Key provided by PrimedIO
* @param connectionString URL to API for PrimedIO service
* @param trackingConnectionString URL to API for PrimedIO tracking service
* @param heartbeatInterval need info
* @param eventQueueRetryInterval need info
* @return PrimedTracker instance
*/
-(PrimedTracker *)initWithPublicKey:(NSString *)publicKey secretKey:(NSString *)secretKey connectionString:(NSString *)connectionString trackingConnectionString:(NSString *)trackingConnectionString heartbeatInterval:(NSInteger)heartbeatInterval eventQueueRetryInterval:(NSInteger)eventQueueRetryInterval;
//PRIMEDTRACKER.trackClick( int x,int y, ClickType clickType)
//PRIMEDTRACKER.trackView(...)
//PRIMEDTRACKER.trackScroll( ScrollDirection direction, int distance)
//PRIMEDTRACKER.trackEnterViewPort( String campaign, Array[int] elements)
//PRIMEDTRACKER.trackEnterViewPort( String campaign, Array[int] elements)
//PRIMEDTRACKER.trackEnterViewPort( String campaign, Array[int] elements)
@end
//
// PrimedTracker.m
// Pods-PrimedIO_Example
//
// Created by Bosko Petreski on 7/23/18.
//
#import "PrimedTracker.h"
@implementation PrimedTracker
-(PrimedTracker *)initWithPublicKey:(NSString *)publicKey secretKey:(NSString *)secretKey connectionString:(NSString *)connectionString trackingConnectionString:(NSString *)trackingConnectionString heartbeatInterval:(NSInteger)heartbeatInterval eventQueueRetryInterval:(NSInteger)eventQueueRetryInterval{
if ((self = [super init])){
}
return self;
}
@end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment