Skip to content

Commit

Permalink
Headers & Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
Heber Lazcano committed Jun 25, 2014
1 parent 6e7b1f4 commit 7893cef
Show file tree
Hide file tree
Showing 29 changed files with 1,608 additions and 0 deletions.
147 changes: 147 additions & 0 deletions DeviceCollectorSDK.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
/**
* @abstract Device Collector SDK for iOS
* @discussion This SDK is used to implement the Dvice Collector in your
* application. Please read through all the documentation before implementing.
*
* Copyright (c) 2012-2013 Kount. All rights reserved.
*/

/**
* @warning *Important* Your application must link with the *UIKit*,
* *SystemConfiguration*, *AdSupport* and *CoreLocation* frameworks to use the
* SDK successfully.
*/
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <AdSupport/AdSupport.h>

/** @name Error Codes */

/**
* Error Codes sent by [DeviceCollectorSDKDelegate onCollectorError]
*/

//NSError trapped. See error for details
#define DC_ERR_NSERROR 1
// Network access not available
#define DC_ERR_NONETWORK 2
// Invalid collector URL
#define DC_ERR_INVALID_URL 3
// Invalid Merchant Id
#define DC_ERR_INVALID_MERCHANT 4
// Invalid Session Id
#define DC_ERR_INVALID_SESSION 5
// Device collection failed
#define DC_ERR_VALIDATION_FAILURE 6

/**
* Optional Collectors. These are enabled by default, but you can
* pass these values into *skipList* and they will be skipped.
*/

// Device ID Collector
#define DC_COLLECTOR_DEVICE_ID @"COLLECTOR_DEVICE_ID"
// Geo Location Collector
#define DC_COLLECTOR_GEO_LOCATION @"COLLECTOR_GEO_LOCATION"

/**
* @protocol DeviceCollectorSDKDelegate
* @abstract Protocol which will provide status updates from a
* DeviceCollectorSDK instance.
*
*/
@protocol DeviceCollectorSDKDelegate <NSObject>
@optional

/**
* @method onCollectorStart
* @abstract Notification that the collector has started.
* @result void
*/
- (void) onCollectorStart;

/**
* @method onCollectorSuccess
* @abstract Notfication that the collector finished successfully.
* @result void
*/
- (void) onCollectorSuccess;

/**
* @method onCollectorError
* @abstract Notification that an error occurred.
*
* @param errorCode Error code
* @param error Triggering error if available
* @result void
*/
- (void) onCollectorError:(int) errorCode
withError:(NSError*) error;
@end // end @protocol DeviceCollectorSDKDelegate

/**
* @class DeviceCollectorSDK
* @abstract Device Collector wrapper object.
*/
@interface DeviceCollectorSDK : NSObject <UIWebViewDelegate>
/**
* @method skipList
* @abstract A list of collectors to skip
* @param list An NSArray of DC_COLLECOTOR_* define values
* @result void
*/
@property (nonatomic, strong) NSArray *skipList;

/**
* @method initWithDebugOn
* @abstract Initialize collector instance.
*
* @param debugLogging Enable/disable logging of debugging messages
* @result A new instance of DeviceCollectorSDK
*/
- (DeviceCollectorSDK*) initWithDebugOn:(bool) debugLogging;

/**
* @method setCollectorUrl
* @abstract Set the URL that the Device Collector will use.
* @discussion This is required PRIOR to calling: method
* [DeviceCollectorSDK collect]
* @param url Full URL to device collector 302-redirect page
* @result void
*/
- (void) setCollectorUrl:(NSString*) url;

/**
* @method setMerchantId
* @abstract Set your Merchant Id.
* @discussion This is required PRIOR to calling: method
* [DeviceCollectorSDK collect]
* @param merc Merchant Id
* @result void
*/
- (void) setMerchantId:(NSString*) merc;

/**
* @method collect
* @abstract Collect device information for the given session.
* @discussion You must set the merchantID and collectorURL prior to
* calling this method using [DeviceCollectorSDK setMerchantId] and
* [DeviceCollectorSDK setCollectorUrl]. Optionally you can set the delegate
* prior to calling collect if you want to get status updates:
* [DeviceCollectorSDK setDelegate]
* @param sessionId Unique session id
* @result void
*/
- (void) collect:(NSString*) sessionId;

/**
* @method setDelegate
* @abstract Set a DeviceCollectorSDKDelegate to notify about collector
* events.
*
* @param delegate Object to notify
* @result void
*/
- (void) setDelegate:(id<DeviceCollectorSDKDelegate>) delegate;
@end // end @interface DeviceCollectorSDK
40 changes: 40 additions & 0 deletions Openpay/OPAddress.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//
// OPAdress.h
// OpenPayIOSApp
//
// Created by Francisco Vieyra on 5/18/14.
// Copyright (c) 2014 OpenPay. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface OPAddress : NSObject

/** Postal code. Required. */
@property NSString * postalCode;

/** First line of address. Required. */
@property NSString * line1;

/** Second line of address. Optional. */
@property NSString * line2;

/** Third line of address. Optional. */
@property NSString * line3;

/** City. Required. */
@property NSString * city;

/** State. Required. */
@property NSString * state;

/** Two-letter ISO 3166-1 country code. Optional. */
@property NSString * countryCode;


- (NSMutableDictionary*) asMutableDictionary;

+(OPAddress*) initWithDictionary: (NSMutableDictionary*) dictionary;


@end
44 changes: 44 additions & 0 deletions Openpay/OPAddress.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//
// OPAdress.m
// OpenPayIOSApp
//
// Created by Francisco Vieyra on 5/18/14.
// Copyright (c) 2014 OpenPay. All rights reserved.
//

#import "OPAddress.h"

@implementation OPAddress

+(OPAddress*) initWithDictionary: (NSMutableDictionary*) dictionary {
if (dictionary == nil || dictionary == NULL || [dictionary class] == [NSNull class]) {
return nil;
}
OPAddress *address = [[OPAddress alloc] init];
address.city = [dictionary objectForKey:@"city"];
address.countryCode = [dictionary objectForKey:@"country_code"];
address.postalCode = [dictionary objectForKey:@"postal_code"];
address.line1 = [dictionary objectForKey:@"line1"];
address.line2 = [dictionary objectForKey:@"line2"];
address.line3 = [dictionary objectForKey:@"line3"];
address.state = [dictionary objectForKey:@"state"];

return address;
}

-(NSMutableDictionary*) asMutableDictionary {

NSMutableDictionary *mutableDictionary = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
self.city, @"city",
self.countryCode, @"country_code",
self.postalCode,@"postal_code",
self.line1,@"line1",
self.line2,@"line2",
self.line3,@"line3",
self.state,@"state", nil];

return mutableDictionary;

}

@end
66 changes: 66 additions & 0 deletions Openpay/OPCard.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
//
// OPCard.h
// OpenPayIOSApp
//
// Created by Francisco Vieyra on 5/18/14.
// Copyright (c) 2014 OpenPay. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "OPAddress.h"

typedef NS_ENUM(NSUInteger, OPCardType)
{
OPCardTypeUnknown,
OPCardTypeVisa,
OPCardTypeMastercard,
OPCardTypeAmericanExpress
};

typedef NS_ENUM(NSUInteger, OPCardSecurityCodeCheck)
{
OPCardSecurityCodeCheckUnknown,
OPCardSecurityCodeCheckPassed,
OPCardSecurityCodeCheckFailed
};

@interface OPCard : NSObject

@property NSDate *creationDate;

@property NSString *id;

@property NSString *bankName;

@property BOOL allowPayouts;

@property NSString *holderName;

@property NSString *expirationMonth;

@property NSString *expirationYear;

@property OPAddress *address;

@property NSString *number;

@property NSString *brand;

@property BOOL allowsCharges;

@property NSString *bankCode;

@property NSString *cvv2;

@property (nonatomic, assign, readonly, getter=getType) OPCardType type;
@property (nonatomic, assign, readonly, getter=getValid) BOOL valid;
@property (nonatomic, assign, readonly, getter=getNumberValid) BOOL numberValid;
@property (nonatomic, assign, readonly, getter=getExpired) BOOL expired;
@property (nonatomic, assign, readonly, getter=getSecurityCodeCheck) OPCardSecurityCodeCheck securityCodeCheck;
@property (nonatomic, strong) NSMutableArray *errors;

- (NSMutableDictionary*) asMutableDictionary;

+ (OPCard*) initWithDictionary: (NSMutableDictionary*) dictionary;

@end
Loading

0 comments on commit 7893cef

Please sign in to comment.