Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create ShopperInsights module and move files there. #853

Merged
merged 12 commits into from
Dec 14, 2023
1 change: 1 addition & 0 deletions ShopperInsights/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
saperi22 marked this conversation as resolved.
Show resolved Hide resolved
11 changes: 11 additions & 0 deletions ShopperInsights/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Shopper Insights Module
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We haven't previously had module-specific READMEs - I'm open to it if we think it's useful and are going to do the same on iOS. What do other think about this?

Copy link
Contributor Author

@saperi22 saperi22 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a strong preference on where to put it, but I'd like to see a short description of each of the modules and what capabilities they provide to the merchant/user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think if we want to move to module specific READMEs this should be done in a separate PR where it's added for all modules vs just one. Though I do feel like a README within a module would be generally difficult to find for merchants. We also typically rely on our public docs to communicate capabilities.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also typically rely on our public docs to communicate capabilities.

Do you mind showing me an example?
While there's the overall capabilities of the SDK, there's probably a distinction we want to make where we let the merchants know what exactly they get by including a particular module.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can totally see a root level MODULES.md or something similar where we can briefly describe what the module does and also what one needs to do to create a new module.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is an example of the PayPal public docs: https://developer.paypal.com/braintree/docs/guides/paypal/overview/android/v4. The overview handles the product overview, then we have the client side + feature specific docs for the client side SDKs as well (our team is responsible for writing these). Typically most features also have a server side integration guide (our team doesn't typically write these) as well as a testing/going live section.

I think we tried having a form of docs live in both the repo and publicly on PPCP but it often resulted in one of the two being out of date so never truly having a "source of truth" for our merchants.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One option might be to have links on the root readme file to the different module's readme files. This would help with the visibility issue.

If the content on each of the module's readme file is small, it might make more sense in the root readme. This way a developer doesn't need to navigate to see what each module does.

Copy link
Contributor Author

@saperi22 saperi22 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is just an overview of the module. I don't see it getting out of date. But that's just me.🤷‍♂️
I can remove the .md if that's how we want to roll.

Copy link
Contributor Author

@saperi22 saperi22 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One option might be to have links on the root readme file to the different module's readme files. This would help with the visibility issue.

We already do that. I probably should have called it out to make it more clear, but yes, that's the intention.

Copy link
Contributor

@hollabaq86 hollabaq86 Dec 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to leverage the public dev docs where possible and avoid additional doc maintenance on our team. We're too small and don't have the bandwidth.

If it's common or accepted practice to the Android dev community that there's a README for each individual module, we can include that file with a basic template that points folks to the public dev docs.

Otherwise, let's not adopt this for the SDK.


This module aims to provide insights about the shopper so the merchant (you!) can prominently
provide the shopper with the shopper's preferred payment option!

To include this module, add the following dependency.
```groovy
dependencies {
implementation 'com.braintreepayments.api:shopper-insights:{version}'
}
```
61 changes: 61 additions & 0 deletions ShopperInsights/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
plugins {
id 'com.android.library'
id 'org.jetbrains.kotlin.android'
saperi22 marked this conversation as resolved.
Show resolved Hide resolved
}

android {
namespace 'com.braintreepayments.api.shopperinsights'
compileSdk rootProject.compileSdkVersion

defaultConfig {
minSdk rootProject.minSdkVersion
targetSdkVersion rootProject.targetSdkVersion

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}

testOptions {
unitTests {
includeAndroidResources = true
all {
jvmArgs '-noverify'
}
}
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}

compileOptions {
sourceCompatibility versions.javaSourceCompatibility
targetCompatibility versions.javaTargetCompatibility
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
implementation deps.coreKtx

testImplementation deps.jsonAssert
testImplementation deps.kotlinTest
testImplementation deps.mockk
}

// region signing and publishing

project.ext.name = "shopper-insights"
project.ext.pom_name = "shopper-insights"
project.ext.group_id = "com.braintreepayments.api"
project.ext.version = rootProject.version
project.ext.pom_desc = "Shopper Insights for Braintree Android."

apply from: rootProject.file("gradle/gradle-publish.gradle")

// endregion
Empty file.
21 changes: 21 additions & 0 deletions ShopperInsights/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
saperi22 marked this conversation as resolved.
Show resolved Hide resolved
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.braintreepayments.api.shopperinsights

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
saperi22 marked this conversation as resolved.
Show resolved Hide resolved
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.braintreepayments.api.shopperinsights.test", appContext.packageName)
}
}
5 changes: 5 additions & 0 deletions ShopperInsights/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.braintreepayments.api.shopperinsights">

</manifest>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

saperi22 marked this conversation as resolved.
Show resolved Hide resolved
/**
* Representation of a user phone number.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

import org.json.JSONObject

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

/**
* A callback that returns information on whether someone is a PayPal or a Venmo shopper.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

import androidx.annotation.VisibleForTesting

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

/**
* Data class encapsulating the result of a shopper insight api request.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

/**
* Data class representing a request for shopper insights.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

/**
* The result object returned when insights about a shopper is requested.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

import org.junit.Test
import org.skyscreamer.jsonassert.JSONAssert
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.braintreepayments.api
package com.braintreepayments.api.shopperinsights

import io.mockk.mockk
import kotlin.test.assertEquals
Expand Down
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ include ':TestUtils'
include ':Demo'
include ':SEPADirectDebit'
include ':PayPalDataCollector'
include ':ShopperInsights'
Loading