<commit_before>//
//  VungleAds.mm
//  AdsProvider Plugin
//
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include "VungleAds.h"

#include "CoronaAssert.h"
#include "CoronaEvent.h"
#include "CoronaLibrary.h"
#include <string>

#import <Foundation/Foundation.h>
#import <VungleSDK/VungleSDK.h>
#import "CoronaRuntime.h"
#import "VungleBytesAssetLoader.h"

static const char* kINCENTIVIZED_AD_TYPE = "incentivized";

// show() ad properties and defaults
static const char* kIS_ANIMATED_KEY = "isAnimated";
static const bool  kIS_ANIMATED_DEFAULT = true;
static const char* kORIENTATIONS = "orientations";
static const char* kIS_SOUND_ENABLED_KEY = "isSoundEnabled";
static const bool  kIS_SOUND_ENABLED_DEFAULT = true;
static const char* kIS_CLOSE_SHOWN_KEY = "isCloseShown";
static const bool  kIS_CLOSE_SHOWN_DEFAULT = true;
static const char* kUSERNAME_KEY = "username";

// events
static const NSString* kEVENT_TYPE_KEY = @"type";
static const NSString* kAD_START_EVENT_TYPE = @"adStart";
static const NSString* kAD_VIEW_EVENT_TYPE = @"adView";
static const NSString* kAD_END_EVENT_TYPE = @"adEnd";
static const NSString* kVERSION = @"2.0.0";

// ----------------------------------------------------------------------------

CORONA_EXPORT
int luaopen_CoronaProvider_ads_vungle( lua_State *L )
{
	return Corona::Vungle::Open( L );
}

@implementation VungleDelegate
@synthesize vungle;

- (void)vungleSDKwillCloseAdWithViewInfo:(NSDictionary *)viewInfo willPresentProductSheet:(BOOL)willPresentProductSheet {
    NSNumber* playTime = [viewInfo objectForKey:@"playTime"] ? [viewInfo objectForKey:@"playTime"] : @(0);
    vungle->DispatchEvent(false, [kAD_VIEW_EVENT_TYPE UTF8String], @{@"secondsWatched": playTime});
    if (!willPresentProductSheet) {
        vungle->DispatchEvent(false, [kAD_END_EVENT_TYPE UTF8String]);
    }
}

- (void)vungleSDKwillCloseProductSheet:(id)productSheet {
    vungle->DispatchEvent(false, [kAD_END_EVENT_TYPE UTF8String]);
}

- (void)vungleSDKwillShowAd {
	vungle->DispatchEvent(false, [kAD_START_EVENT_TYPE UTF8String]);
}
@end

// ----------------------------------------------------------------------------

namespace Corona
{

// ----------------------------------------------------------------------------

const char Vungle::kName[] = "CoronaProvider.ads.vungle";
static const char kProviderName[] = "vungle";
static const char kPublisherId[] = "com.vungle";


Vungle* vungleProvider = NULL;

int
Vungle::Open( lua_State *L )<commit_msg>missing key in iOS event<commit_after>//
//  VungleAds.mm
//  AdsProvider Plugin
//
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#include "VungleAds.h"

#include "CoronaAssert.h"
#include "CoronaEvent.h"
#include "CoronaLibrary.h"
#include <string>

#import <Foundation/Foundation.h>
#import <VungleSDK/VungleSDK.h>
#import "CoronaRuntime.h"
#import "VungleBytesAssetLoader.h"

static const char* kINCENTIVIZED_AD_TYPE = "incentivized";

// show() ad properties and defaults
static const char* kIS_ANIMATED_KEY = "isAnimated";
static const bool  kIS_ANIMATED_DEFAULT = true;
static const char* kORIENTATIONS = "orientations";
static const char* kIS_SOUND_ENABLED_KEY = "isSoundEnabled";
static const bool  kIS_SOUND_ENABLED_DEFAULT = true;
static const char* kIS_CLOSE_SHOWN_KEY = "isCloseShown";
static const bool  kIS_CLOSE_SHOWN_DEFAULT = true;
static const char* kUSERNAME_KEY = "username";
static const char* kIS_COMPLETED_VIEW = "isCompletedView";

// events
static const NSString* kEVENT_TYPE_KEY = @"type";
static const NSString* kAD_START_EVENT_TYPE = @"adStart";
static const NSString* kAD_VIEW_EVENT_TYPE = @"adView";
static const NSString* kAD_END_EVENT_TYPE = @"adEnd";
static const NSString* kVERSION = @"2.0.0";

// ----------------------------------------------------------------------------

CORONA_EXPORT
int luaopen_CoronaProvider_ads_vungle( lua_State *L )
{
	return Corona::Vungle::Open( L );
}

@implementation VungleDelegate
@synthesize vungle;

- (void)vungleSDKwillCloseAdWithViewInfo:(NSDictionary *)viewInfo willPresentProductSheet:(BOOL)willPresentProductSheet {
    NSNumber* playTime = [viewInfo objectForKey:@"playTime"] ? [viewInfo objectForKey:@"playTime"] : @(0);
    vungle->DispatchEvent(false, [kAD_VIEW_EVENT_TYPE UTF8String], @{@"secondsWatched": playTime, @"isCompletedView": [viewInfo objectForKey:@"completedView"]});
    if (!willPresentProductSheet) {
        vungle->DispatchEvent(false, [kAD_END_EVENT_TYPE UTF8String]);
    }
}

- (void)vungleSDKwillCloseProductSheet:(id)productSheet {
    vungle->DispatchEvent(false, [kAD_END_EVENT_TYPE UTF8String]);
}

- (void)vungleSDKwillShowAd {
	vungle->DispatchEvent(false, [kAD_START_EVENT_TYPE UTF8String]);
}
@end

// ----------------------------------------------------------------------------

namespace Corona
{

// ----------------------------------------------------------------------------

const char Vungle::kName[] = "CoronaProvider.ads.vungle";
static const char kProviderName[] = "vungle";
static const char kPublisherId[] = "com.vungle";


Vungle* vungleProvider = NULL;

int
Vungle::Open( lua_State *L )
{'fraction_non_alphanumeric': 0.19922027290448344, 'fraction_numerical': 0.004678362573099415, 'mean_word_length': 3.6142086330935252, 'pattern_counts': {'":': 3, '<': 9, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6165099', 'n_tokens_mistral': 1694, 'n_tokens_neox': 1602, 'n_words': 350}