Skip to content

Commit

Permalink
Kount iOS SDK v3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
tuyen-vuduc committed May 28, 2017
1 parent 68cc058 commit 2172b4a
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Autosave files
*~

# build
[Oo]bj/
[Bb]in/
packages/
TestResults/

# globs
Makefile.in
*.DS_Store
*.sln.cache
*.suo
*.cache
*.pidb
*.userprefs
*.usertasks
config.log
config.make
config.status
aclocal.m4
install-sh
autom4te.cache/
*.user
*.tar.gz
tarballs/
test-results/
Thumbs.db

# Mac bundle stuff
*.dmg
*.app

# resharper
*_Resharper.*
*.Resharper

# dotCover
*.dotCover
*.nupkg
54 changes: 54 additions & 0 deletions KountDataCollector/ApiDefinitions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using Foundation;
using ObjCRuntime;

namespace Kount
{
[Static]
[Verify (ConstantsInterfaceAssociation)]
partial interface Constants
{
// extern NSString *const _Nonnull KDataCollectorErrorDomain;
[Field ("KDataCollectorErrorDomain", "__Internal")]
NSString KDataCollectorErrorDomain { get; }

// extern NSString *const _Nonnull KDataCollectorVersion;
[Field ("KDataCollectorVersion", "__Internal")]
NSString KDataCollectorVersion { get; }
}

// @interface KDataCollector : NSObject
[BaseType (typeof(NSObject))]
interface KDataCollector
{
// +(KDataCollector * _Nonnull)sharedCollector;
[Static]
[Export ("sharedCollector")]
[Verify (MethodToProperty)]
KDataCollector SharedCollector { get; }

// @property NSInteger merchantID;
[Export ("merchantID")]
nint MerchantID { get; set; }

// @property KLocationCollectorConfig locationCollectorConfig;
[Export ("locationCollectorConfig", ArgumentSemantic.Assign)]
KLocationCollectorConfig LocationCollectorConfig { get; set; }

// @property BOOL debug;
[Export ("debug")]
bool Debug { get; set; }

// @property NSInteger timeoutInMS;
[Export ("timeoutInMS")]
nint TimeoutInMS { get; set; }

// @property KEnvironment environment;
[Export ("environment", ArgumentSemantic.Assign)]
KEnvironment Environment { get; set; }

// -(void)collectForSession:(NSString * _Nonnull)sessionID completion:(void (^ _Nullable)(NSString * _Nonnull, BOOL, NSError * _Nullable))completionBlock;
[Export ("collectForSession:completion:")]
void CollectForSession (string sessionID, [NullAllowed] Action<NSString, bool, NSError> completionBlock);
}
}
104 changes: 104 additions & 0 deletions KountDataCollector/KDataCollector.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
//
// KDataCollector.h
// Kount Data Collector SDK
//
// Copyright © 2016 Kount Inc. All rights reserved.
//

#import <Foundation/Foundation.h>

// Error Codes
typedef NS_ENUM(NSInteger, KDataCollectorErrorCode) {

KDataCollectorErrorCodeUnknown = 0,

// A system error occurred
KDataCollectorErrorCodeNSError,

// A required collector timed out
KDataCollectorErrorCodeTimeout,

// A bad parameter was passed into the data collector
KDataCollectorErrorCodeBadParameter,

// A network connection isn't available
KDataCollectorErrorCodeNoNetwork,

// An error occurred while validating a response from the server
KDataCollectorErrorCodeResponseValidation,
};

NS_ASSUME_NONNULL_BEGIN

extern NSString *const KDataCollectorErrorDomain;

// Version of the Kount Data Collector SDK
extern NSString *const KDataCollectorVersion;

// Configuration settings for location collection
typedef NS_ENUM(NSInteger, KLocationCollectorConfig) {

// Request permission if not currently authorized (default)
KLocationCollectorConfigRequestPermission = 0,

// Only collect if app already has location permissions
// (use in cases where requesting permission is done by the app itself)
KLocationCollectorConfigPassive,

// Skip location collection
KLocationCollectorConfigSkip,
};

// Configuration settings Kount collection environment
typedef NS_ENUM(NSInteger, KEnvironment) {

// Unknown Environment
KEnvironmentUnknown = 0,

// Test Environment
KEnvironmentTest,

// Production Environment
KEnvironmentProduction,
};

// KDataCollector enables you to collect device information for the given session
//
// First, configure the collector during the initialization of your application
// Second, call collectForSession when you start the payment checkout process
//
@interface KDataCollector : NSObject

// Get the shared instance of the Data Collector
+ (KDataCollector *)sharedCollector;

//
// Configuration
//

// The Kount Merchant ID
@property NSInteger merchantID;
// The configuration of the location collector to determine if and how it goes about collection location
@property KLocationCollectorConfig locationCollectorConfig;
// Debug logging to the console
@property BOOL debug;
// Timeout in MS for the collection
@property NSInteger timeoutInMS;
// The Kount environment
@property KEnvironment environment;

//
// Collection
//

// Collect data for the session.
//
// @param sessionID A unique session ID that should match the sessionID for the payment transaction
// @param completionBlock This completion block will be called when the collection has completed or an error occurs.
- (void)collectForSession:(NSString *)sessionID completion:(nullable void (^)(NSString *_Nonnull sessionID, BOOL success, NSError *_Nullable error))completionBlock;

NS_ASSUME_NONNULL_END

@end


32 changes: 32 additions & 0 deletions KountDataCollector/StructsAndEnums.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using ObjCRuntime;

namespace Kount
{
[Native]
public enum KDataCollectorErrorCode : nint
{
Unknown = 0,
NSError,
Timeout,
BadParameter,
NoNetwork,
ResponseValidation
}

[Native]
public enum KLocationCollectorConfig : nint
{
RequestPermission = 0,
Passive,
Skip
}

[Native]
public enum KEnvironment : nint
{
Unknown = 0,
Test,
Production
}
}
Binary file added KountDataCollector/libKountDataCollector.a
Binary file not shown.
40 changes: 40 additions & 0 deletions Naxam.Kount.iOS/ApiDefinition.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using System;
using Foundation;
using ObjCRuntime;

namespace Kount
{
// @interface KDataCollector : NSObject
[BaseType (typeof(NSObject))]
interface KDataCollector
{
// +(KDataCollector * _Nonnull)sharedCollector;
[Static]
[Export ("sharedCollector")]
KDataCollector SharedCollector { get; }

// @property NSInteger merchantID;
[Export ("merchantID")]
nint MerchantID { get; set; }

// @property KLocationCollectorConfig locationCollectorConfig;
[Export ("locationCollectorConfig", ArgumentSemantic.Assign)]
KLocationCollectorConfig LocationCollectorConfig { get; set; }

// @property BOOL debug;
[Export ("debug")]
bool Debug { get; set; }

// @property NSInteger timeoutInMS;
[Export ("timeoutInMS")]
nint TimeoutInMS { get; set; }

// @property KEnvironment environment;
[Export ("environment", ArgumentSemantic.Assign)]
KEnvironment Environment { get; set; }

// -(void)collectForSession:(NSString * _Nonnull)sessionID completion:(void (^ _Nullable)(NSString * _Nonnull, BOOL, NSError * _Nullable))completionBlock;
[Export ("collectForSession:completion:")]
void CollectForSession (string sessionID, [NullAllowed] Action<NSString, bool, NSError> completionBlock);
}
}
50 changes: 50 additions & 0 deletions Naxam.Kount.iOS/Naxam.Kount.iOS.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{552FBFA1-75F9-44A6-8A2F-98CBE6FE4E5E}</ProjectGuid>
<ProjectTypeGuids>{8FFB629D-F513-41CE-95D2-7ECE97B6EEEC};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<RootNamespace>Naxam.Kount.iOS</RootNamespace>
<AssemblyName>Naxam.Kount.iOS</AssemblyName>
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<Optimize>true</Optimize>
<OutputPath>bin\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="Xamarin.iOS" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingApiDefinition Include="ApiDefinition.cs" />
</ItemGroup>
<ItemGroup>
<ObjcBindingCoreSource Include="Structs.cs" />
</ItemGroup>
<ItemGroup>
<NativeReference Include="..\KountDataCollector\libKountDataCollector.a">
<Kind>Static</Kind>
<SmartLink>False</SmartLink>
</NativeReference>
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.ObjCBinding.CSharp.targets" />
</Project>
34 changes: 34 additions & 0 deletions Naxam.Kount.iOS/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System.Reflection;
using System.Runtime.CompilerServices;

using Foundation;

// This attribute allows you to mark your assemblies as “safe to link”.
// When the attribute is present, the linker—if enabled—will process the assembly
// even if you’re using the “Link SDK assemblies only” option, which is the default for device builds.

[assembly: LinkerSafe]

// Information about this assembly is defined by the following attributes.
// Change them to the values specific to your project.

[assembly: AssemblyTitle("Naxam.Kount.iOS")]
[assembly: AssemblyDescription("Xamarin Binding Library - Kount iOS SDK")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("NAXAM COMPANY LIMITED")]
[assembly: AssemblyProduct("X Bindings")]
[assembly: AssemblyCopyright("Copyright (c) 2017 NAXAM")]
[assembly: AssemblyTrademark("NAXAM")]
[assembly: AssemblyCulture("")]

// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.

[assembly: AssemblyVersion("3.1.0")]

// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.

//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
32 changes: 32 additions & 0 deletions Naxam.Kount.iOS/Structs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using ObjCRuntime;

namespace Kount
{
[Native]
public enum KDataCollectorErrorCode : long
{
Unknown = 0,
NSError,
Timeout,
BadParameter,
NoNetwork,
ResponseValidation
}

[Native]
public enum KLocationCollectorConfig : long
{
RequestPermission = 0,
Passive,
Skip
}

[Native]
public enum KEnvironment : long
{
Unknown = 0,
Test,
Production
}
}
Loading

0 comments on commit 2172b4a

Please sign in to comment.