commit a0342ca4c363f8d7f32f0d4867594055058ea7ec Author: gilo Date: Sun Jan 27 08:39:49 2019 +0300 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2b75303 --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +*.iml +.gradle +/local.properties +/.idea/caches +/.idea/libraries +/.idea/modules.xml +/.idea/workspace.xml +/.idea/navEditor.xml +/.idea/assetWizardSettings.xml +.DS_Store +/build +/captures +.externalNativeBuild diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..34dc27c --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,35 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 0000000..79ee123 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..2ed8e73 --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..b6ea2b1 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/app/.gitignore @@ -0,0 +1 @@ +/build diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..04a8cdf --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,34 @@ +apply plugin: 'com.android.application' + +apply plugin: 'kotlin-android' + +apply plugin: 'kotlin-android-extensions' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "me.gilo.wc_app" + minSdkVersion 15 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" + implementation 'com.android.support:appcompat-v7:28.0.0' + implementation 'com.android.support.constraint:constraint-layout:1.1.3' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + compile project(path: ':woodroid') +} diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# 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 diff --git a/app/src/androidTest/java/me/gilo/wc_app/ExampleInstrumentedTest.kt b/app/src/androidTest/java/me/gilo/wc_app/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..3c02a45 --- /dev/null +++ b/app/src/androidTest/java/me/gilo/wc_app/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package me.gilo.wc_app + +import android.support.test.InstrumentationRegistry +import android.support.test.runner.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 { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getTargetContext() + assertEquals("me.gilo.wc_app", appContext.packageName) + } +} diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..fb7ba52 --- /dev/null +++ b/app/src/main/AndroidManifest.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/java/me/gilo/wc_app/MainActivity.kt b/app/src/main/java/me/gilo/wc_app/MainActivity.kt new file mode 100644 index 0000000..13bb676 --- /dev/null +++ b/app/src/main/java/me/gilo/wc_app/MainActivity.kt @@ -0,0 +1,28 @@ +package me.gilo.wc_app + +import android.arch.lifecycle.Observer +import android.support.v7.app.AppCompatActivity +import android.os.Bundle +import android.util.Log +import me.gilo.woodroid.Woocommerce +import me.gilo.woodroid.Woocommerce.Builder +import me.gilo.woodroid.callback.Status + +class MainActivity : AppCompatActivity() { + + val TAG = "MainActivity"; + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setContentView(R.layout.activity_main) + + val woocommerce = Builder() + .setSiteUrl("") + .setApiVersion("") + .setConsumerKey("") + .setConsumerSecret("") + .build() + + woocommerce.products. + } +} diff --git a/app/src/main/res/drawable-v24/ic_launcher_foreground.xml b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml new file mode 100644 index 0000000..6348baa --- /dev/null +++ b/app/src/main/res/drawable-v24/ic_launcher_foreground.xml @@ -0,0 +1,34 @@ + + + + + + + + + + + diff --git a/app/src/main/res/drawable/ic_launcher_background.xml b/app/src/main/res/drawable/ic_launcher_background.xml new file mode 100644 index 0000000..a0ad202 --- /dev/null +++ b/app/src/main/res/drawable/ic_launcher_background.xml @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..980638c --- /dev/null +++ b/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,19 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml new file mode 100644 index 0000000..bbd3e02 --- /dev/null +++ b/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..898f3ed Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png new file mode 100644 index 0000000..dffca36 Binary files /dev/null and b/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..64ba76f Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png new file mode 100644 index 0000000..dae5e08 Binary files /dev/null and b/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..e5ed465 Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png new file mode 100644 index 0000000..14ed0af Binary files /dev/null and b/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..b0907ca Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..d8ae031 Binary files /dev/null and b/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png new file mode 100644 index 0000000..2c18de9 Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png new file mode 100644 index 0000000..beed3cd Binary files /dev/null and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml new file mode 100644 index 0000000..69b2233 --- /dev/null +++ b/app/src/main/res/values/colors.xml @@ -0,0 +1,6 @@ + + + #008577 + #00574B + #D81B60 + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml new file mode 100644 index 0000000..b100bf1 --- /dev/null +++ b/app/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + wc-app + diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml new file mode 100644 index 0000000..5885930 --- /dev/null +++ b/app/src/main/res/values/styles.xml @@ -0,0 +1,11 @@ + + + + + + diff --git a/app/src/test/java/me/gilo/wc_app/ExampleUnitTest.kt b/app/src/test/java/me/gilo/wc_app/ExampleUnitTest.kt new file mode 100644 index 0000000..816cbb2 --- /dev/null +++ b/app/src/test/java/me/gilo/wc_app/ExampleUnitTest.kt @@ -0,0 +1,17 @@ +package me.gilo.wc_app + +import org.junit.Test + +import org.junit.Assert.* + +/** + * Example local unit test, which will execute on the development machine (host). + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +class ExampleUnitTest { + @Test + fun addition_isCorrect() { + assertEquals(4, 2 + 2) + } +} diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..e49a8b8 --- /dev/null +++ b/build.gradle @@ -0,0 +1,28 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + ext.kotlin_version = '1.3.11' + repositories { + google() + jcenter() + + } + dependencies { + classpath 'com.android.tools.build:gradle:3.4.0-alpha01' + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..85be9ea --- /dev/null +++ b/gradle.properties @@ -0,0 +1,15 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# Kotlin code style for this project: "official" or "obsolete": +kotlin.code.style=official diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..f6b961f Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..7b41a04 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Wed Jan 16 04:39:39 EAT 2019 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip diff --git a/gradlew b/gradlew new file mode 100755 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..d23f552 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app', ':woodroid' diff --git a/woodroid/.gitignore b/woodroid/.gitignore new file mode 100644 index 0000000..796b96d --- /dev/null +++ b/woodroid/.gitignore @@ -0,0 +1 @@ +/build diff --git a/woodroid/build.gradle b/woodroid/build.gradle new file mode 100644 index 0000000..f168429 --- /dev/null +++ b/woodroid/build.gradle @@ -0,0 +1,50 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 28 + + + + defaultConfig { + minSdkVersion 15 + targetSdkVersion 28 + versionCode 1 + versionName "1.0" + + testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" + + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + } + } + + compileOptions { + sourceCompatibility = '1.8' + targetCompatibility = '1.8' + } + +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + + implementation 'com.android.support:appcompat-v7:28.0.0' + testImplementation 'junit:junit:4.12' + androidTestImplementation 'com.android.support.test:runner:1.0.2' + androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' + + implementation 'com.squareup.retrofit2:retrofit:2.3.0' + implementation 'com.squareup.retrofit2:converter-gson:2.3.0' + + implementation 'org.apache.httpcomponents:httpclient:4.4-alpha1' + implementation 'com.jakewharton.retrofit:retrofit1-okhttp3-client:1.1.0' + + implementation 'io.reactivex:rxandroid:1.2.1' + implementation 'io.reactivex:rxjava:1.3.0' + + implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0' +} diff --git a/woodroid/proguard-rules.pro b/woodroid/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/woodroid/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# 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 diff --git a/woodroid/src/androidTest/java/me/gilo/woodroid/ExampleInstrumentedTest.java b/woodroid/src/androidTest/java/me/gilo/woodroid/ExampleInstrumentedTest.java new file mode 100644 index 0000000..f9d486c --- /dev/null +++ b/woodroid/src/androidTest/java/me/gilo/woodroid/ExampleInstrumentedTest.java @@ -0,0 +1,26 @@ +package me.gilo.woodroid; + +import android.content.Context; +import android.support.test.InstrumentationRegistry; +import android.support.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import static org.junit.Assert.*; + +/** + * Instrumented test, which will execute on an Android device. + * + * @see Testing documentation + */ +@RunWith(AndroidJUnit4.class) +public class ExampleInstrumentedTest { + @Test + public void useAppContext() { + // Context of the app under test. + Context appContext = InstrumentationRegistry.getTargetContext(); + + assertEquals("me.gilo.woodroid.test", appContext.getPackageName()); + } +} diff --git a/woodroid/src/main/AndroidManifest.xml b/woodroid/src/main/AndroidManifest.xml new file mode 100644 index 0000000..dee738a --- /dev/null +++ b/woodroid/src/main/AndroidManifest.xml @@ -0,0 +1,2 @@ + diff --git a/woodroid/src/main/java/me/gilo/woodroid/Woocommerce.java b/woodroid/src/main/java/me/gilo/woodroid/Woocommerce.java new file mode 100644 index 0000000..0c776d3 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/Woocommerce.java @@ -0,0 +1,102 @@ +package me.gilo.woodroid; + +import me.gilo.woodroid.models.Product; +import me.gilo.woodroid.repo.ProductRepository; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +import java.util.ArrayList; + +public class Woocommerce { + + private String baseUrl; + private String siteUrl; + private String apiVerion; + private String consumerKey; + private String consumerSecret; + + final ProductRepository productRepository; + + public static void main(String args[]){ + System.out.println("Hello"); + + Woocommerce woocommerce = new Woocommerce.Builder() + .setSiteUrl("http://iappsdevelopers.com/codecan/woodroid") + .setApiVersion("2") + .setConsumerKey("ck_62b755890341ad3d2bd334433d30b5070eea349f") + .setConsumerSecret("cs_8f678fedc94cbf520e0240d6eacab4dab2954aaa") + .build(); + + + woocommerce.getProducts().enqueue(new Callback>() { + @Override + public void onResponse(Call> call, Response> response) { + ArrayList products = response.body(); + for (Product product : products){ + System.out.println(product.getTitle()); + } + } + + @Override + public void onFailure(Call> call, Throwable t) { + + } + }); + } + + public Woocommerce(String siteUrl, String apiVerion, String consumerKey, String consumerSecret) { + this.siteUrl = siteUrl; + this.apiVerion = apiVerion; + this.consumerKey = consumerKey; + this.consumerSecret = consumerSecret; + + this.baseUrl = siteUrl + "/wp-json/wc/v" + apiVerion + "/"; + + productRepository = new ProductRepository(baseUrl, consumerKey, consumerSecret); + } + + + public static class Builder { + private String siteUrl; + private String apiVerion; + private String consumerKey; + private String consumerSecret; + + + public Builder() { + } + + public Builder setSiteUrl(String siteUrl) { + this.siteUrl = siteUrl; + return this; + } + + public Builder setApiVersion(String apiVerion) { + this.apiVerion = apiVerion; + return this; + } + + public Builder setConsumerKey(String consumerKey) { + this.consumerKey = consumerKey; + return this; + } + + public Builder setConsumerSecret(String consumerSecret) { + this.consumerSecret = consumerSecret; + return this; + } + + + public Woocommerce build() { + return new Woocommerce(siteUrl, apiVerion, consumerKey, consumerSecret); + } + } + + + public Call> getProducts() { + return productRepository.products(); + } + + +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/callback/CallBackLiveData.java b/woodroid/src/main/java/me/gilo/woodroid/callback/CallBackLiveData.java new file mode 100644 index 0000000..225603c --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/callback/CallBackLiveData.java @@ -0,0 +1,39 @@ +package me.gilo.woodroid.callback; + +import android.arch.lifecycle.LiveData; +import retrofit2.Call; +import retrofit2.Callback; +import retrofit2.Response; + +import java.io.IOException; + +public class CallBackLiveData extends LiveData> implements Callback { + + public CallBackLiveData() { + setValue(new Resource<>(Status.LOADING)); + } + + @Override + public void onResponse(Call call, Response response) { + if (response.isSuccessful()){ + setValue(new Resource<>(response.body())); + }else{ + String error = null; + try { + error = response.errorBody().string(); + } catch (IOException e) { + e.printStackTrace(); + } + + if (error == null){ + error = "Something went wrong"; + } + setValue(new Resource<>(new NetworkException(error))); + } + } + + @Override + public void onFailure(Call call, Throwable t) { + setValue(new Resource<>( new NetworkException(t))); + } +} \ No newline at end of file diff --git a/woodroid/src/main/java/me/gilo/woodroid/callback/NetworkException.java b/woodroid/src/main/java/me/gilo/woodroid/callback/NetworkException.java new file mode 100644 index 0000000..3be2e40 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/callback/NetworkException.java @@ -0,0 +1,20 @@ +package me.gilo.woodroid.callback; + +public class NetworkException extends Exception{ + + public NetworkException() { + super(); + } + + public NetworkException(String message) { + super(message); + } + + public NetworkException(String message, Throwable cause) { + super(message, cause); + } + + public NetworkException(Throwable cause) { + super(cause); + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/callback/Resource.java b/woodroid/src/main/java/me/gilo/woodroid/callback/Resource.java new file mode 100755 index 0000000..0dd25d8 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/callback/Resource.java @@ -0,0 +1,79 @@ +package me.gilo.woodroid.callback; + +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; +import android.util.Log; + +import java.util.List; + + +@SuppressWarnings({"WeakerAccess", "ConstantConditions"}) +public final class Resource { + @Nullable + private final T data; + @Nullable + private final Exception error; + Status status = Status.LOADING; + + public Resource(@NonNull T data) { + this(data, null); + } + + public Resource(@NonNull Status status) { + this(null, null); + this.status = status; + } + + public Resource(@NonNull Exception exception) { + this(null, exception); + this.status = Status.ERROR; + } + + private Resource(@Nullable T value, @Nullable Exception error) { + this.data = value; + this.error = error; + + if (error != null){ + status = Status.ERROR; + }else if (data != null){ + if (data instanceof List){ + if (((List) data).size() == 0){ + status = Status.EMPTY; + }else { + status = status.SUCCESS; + } + }else { + status = Status.SUCCESS; + } + }else { + status = Status.LOADING; + } + } + + public boolean isSuccessful() { + return data != null && error == null; + } + + @NonNull + public T data() { + if (error != null) { + throw new IllegalStateException("error is not null. Call isSuccessful() first."); + } + return data; + } + + @NonNull + public Exception error() { + if (data != null) { + throw new IllegalStateException("data is not null. Call isSuccessful() first."); + } + return error; + } + + @NonNull + public Status status() { + return status; + } + + +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/callback/Status.java b/woodroid/src/main/java/me/gilo/woodroid/callback/Status.java new file mode 100644 index 0000000..e78ff15 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/callback/Status.java @@ -0,0 +1,12 @@ +package me.gilo.woodroid.callback; + +public enum Status { + EMPTY, + SUCCESS, + ERROR, + LOADING; + + public Status isLoading(){ + return LOADING; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/API.java b/woodroid/src/main/java/me/gilo/woodroid/data/API.java new file mode 100644 index 0000000..3b534fa --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/API.java @@ -0,0 +1,168 @@ +package me.gilo.woodroid.data; + + +import me.gilo.woodroid.data.callbacks.*; +import me.gilo.woodroid.data.callbacks.Data; +import me.gilo.woodroid.models.*; +import retrofit2.Call; +import retrofit2.http.*; +import rx.Observable; + +import java.util.ArrayList; +import java.util.Map; + +public interface API { + + @GET + Observable store(@Url String url); + + //////////////////////////////////////////////////////////////////////// + //products + //////////////////////////////////////////////////////////////////////// + @GET("products/categories") + Call> getCategories(); + + @GET + Call getCategories2(@Url String url); + + @GET("products") + Call> getProducts(); + + @GET("products") + Call> getProducts(@Query("filter[category]") String category); + + @GET("products") + Call> search(@Query("search") String search); + + @GET + Call getProductReviews(@Url String url); + + @GET("products") + Call> filter(@QueryMap Map filter); + + @GET("products/{id}") + Call getRelatedProducts(@Path("id") int id); + + @GET("products/{id}") + Call getProduct(@Path("id") int id); + + //////////////////////////////////////////////////////////////////////// + //orders + //////////////////////////////////////////////////////////////////////// + @GET("orders") + Observable getOrders(); + + @Headers("Content-Type: application/json") + @POST("orders") + Call createOrder(@Body OrderData order); + + //////////////////////////////////////////////////////////////////////// + //customer + //////////////////////////////////////////////////////////////////////// + @GET + Observable viewMyOrders(@Url String url); + + @Headers("Content-Type: application/json") + @POST("customers") + Call registerUser(@Body CustomerData body); + + @Headers("Content-Type: application/json") + @POST("customers") + Call registerUser2(@Body Data body); + + @GET + Call loginUser(@Url String url); + + @GET("customers/email/{email}") + Call loginUser2(@Path("email") String email); + + //////////////////////////////////////////////////////////////////////// + //Coupons + //////////////////////////////////////////////////////////////////////// + + @Headers("Content-Type: application/json") + @POST("coupons") + Call createCoupon(@Body Coupon body); + + @GET("coupons/{id}") + Call viewCoupon(@Path("id") int id); + + @GET("coupons/count") + Call viewCouponCount(); + + @GET("coupons") + Observable viewCouponList(@Path("id") int id); + + @PUT("coupons/{id}") + Call updateCoupon(@Path("id") int id); + + @DELETE("coupons/{id}") + Call deleteCoupon(@Path("id") int id); + + /////////////////////////////////////////////////////////////////////// + //Cart + //////////////////////////////////////////////////////////////////////// + + + + + + /* + + + /coupons + /coupons/count + /coupons/ + /coupons/code/ + /coupons/bulk + /customers + /customers/count + /customers/ + /customers/email/ + /customers//orders + /customers//downloads + /customers/bulk + /orders + /orders/count + /orders/statuses + /orders/ + /orders//notes + /orders//notes/ + /orders//refunds + /orders//refunds/ + /orders/bulk + /products + /products/count + /products/ + /products//reviews + /products//orders + /products/categories + /products/categories/ + /products/tags + /products/tags/ + /products/shipping_classes + /products/shipping_classes/ + /products/attributes + /products/attributes/ + /products/attributes//terms + /products/attributes//terms/ + /products/bulk + /reports + /reports/sales + /reports/sales/top_sellers + /taxes + /taxes/count + /taxes/ + /taxes/classes + /taxes/classes/count + /taxes/classes/ + /taxes/bulk + /webhooks + /webhooks/count + /webhooks/ + /webhooks//deliveries + /webhooks//deliveries/ + + */ + +} \ No newline at end of file diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/ProductAPI.java b/woodroid/src/main/java/me/gilo/woodroid/data/ProductAPI.java new file mode 100644 index 0000000..6bc1167 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/ProductAPI.java @@ -0,0 +1,70 @@ +package me.gilo.woodroid.data; + + +import me.gilo.woodroid.data.callbacks.*; +import me.gilo.woodroid.data.callbacks.Data; +import me.gilo.woodroid.models.*; +import retrofit2.Call; +import retrofit2.http.*; +import rx.Observable; + +import java.util.ArrayList; +import java.util.Map; + +public interface ProductAPI { + + + @GET("products/categories") + Call> getCategories(); + + @GET("products") + Call> getProducts(); + + @GET("products/{id}") + Call getProduct(@Path("id") int id); + + @GET("products") + Call> getProducts(@Query("filter[category]") String category); + + @GET("products") + Call> search(@Query("search") String search); + + @GET("products") + Call> filter(@QueryMap Map filter); + + @GET("products/{id}") + Call getRelatedProducts(@Path("id") int id); + + + @GET("products/count") + Call> getProductsCount(); + + @GET("products/{id}/reviews") + Call getProductReviews(@Path("id") int id); + + @GET("products/{id}/orders") + Call getProductOrders(@Path("id") int id); + + + + + /* + /products + /products/count + /products/ + /products//reviews + /products//orders + /products/categories + /products/categories/ + /products/tags + /products/tags/ + /products/shipping_classes + /products/shipping_classes/ + /products/attributes + /products/attributes/ + /products/attributes//terms + /products/attributes//terms/ + /products/bulk + */ + +} \ No newline at end of file diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/RestAdapter.java b/woodroid/src/main/java/me/gilo/woodroid/data/RestAdapter.java new file mode 100644 index 0000000..9b04072 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/RestAdapter.java @@ -0,0 +1,227 @@ +package me.gilo.woodroid.data; + +import android.util.Base64; +import android.util.Log; + +import okhttp3.HttpUrl; +import okhttp3.Interceptor; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.Response; + +import org.apache.http.NameValuePair; +import org.apache.http.client.utils.URLEncodedUtils; +import org.apache.http.message.BasicNameValuePair; + +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.net.URLEncoder; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.Iterator; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import javax.crypto.Mac; +import javax.crypto.spec.SecretKeySpec; + +import okhttp3.logging.HttpLoggingInterceptor; +import retrofit2.Retrofit; +import retrofit2.converter.gson.GsonConverterFactory; + +public class RestAdapter { + + static String oauth_nonce = ""; + static String oauth_timestamp = ""; + static String oauth_signature_method = "HMAC-SHA1"; + + static ArrayList params; + + private String baseUrl; + private String consumerKey; + private String consumerSecret; + + public RestAdapter(String baseUrl, String consumerKey, String consumerSecret) { + this.baseUrl = baseUrl; + this.consumerKey = consumerKey; + this.consumerSecret = consumerSecret; + } + + public API createAPI(final String endpoint) { + return createAPI(endpoint, null); + } + + public API createAPI(final String endpoint, Map query) { + + if (query != null) { + setParams(endpoint, query); + }else{ + setParams(endpoint); + } + + // Define the interceptor, add authentication headers + Interceptor interceptor = chain -> { + + HttpUrl.Builder builder = chain.request().url().newBuilder(); + for (NameValuePair entry : params) { + builder.addQueryParameter(entry.getName(), entry.getValue()); + } + + Request newRequest = chain.request() + .newBuilder() + .url(builder.build()) + .header("Accept", "application/json") + .build(); + + return chain.proceed(newRequest); + }; + + HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor(); + loggingInterceptor.setLevel(HttpLoggingInterceptor.Level.BODY); + + OkHttpClient client = new OkHttpClient.Builder() + .addInterceptor(interceptor) + .addInterceptor(loggingInterceptor) + .readTimeout(30, TimeUnit.SECONDS) + .writeTimeout(30, TimeUnit.SECONDS) + .connectTimeout(15, TimeUnit.SECONDS) + .build(); + + Retrofit retrofit = new Retrofit.Builder() + .baseUrl(baseUrl) + //.addCallAdapterFactory(RxJavaCallAdapterFactory.create()) + .addConverterFactory(GsonConverterFactory.create()) + .client(client) + .build(); + + return retrofit.create(API.class); + } + + public ArrayList setParams(String endpoint) { + final String uri = baseUrl + endpoint; + + URI uri1 = URI.create(baseUrl + endpoint); + String urlString = ""; + try { + URL url = uri1.toURL(); + urlString = url.toString(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + + oauth_nonce = getOauth_nonce(); + oauth_timestamp = getOauth_timestamp(); + + params = new ArrayList<>(); + params.add(new BasicNameValuePair("oauth_consumer_key", consumerKey)); + params.add(new BasicNameValuePair("oauth_nonce", oauth_nonce)); + params.add(new BasicNameValuePair("oauth_timestamp", oauth_timestamp)); + params.add(new BasicNameValuePair("oauth_signature_method", oauth_signature_method)); + + Collections.sort(params, new SortParams()); + + String encodedParams = URLEncodedUtils.format(params, "utf-8"); + + String string_to_sign = ""; + try { + string_to_sign = (new StringBuilder("GET&")).append(URLEncoder.encode(uri, "utf-8")).append("&").append(URLEncoder.encode(encodedParams, "utf-8")).toString(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + + try { + Mac mac = Mac.getInstance("HMAC-SHA1"); + String secret = consumerSecret + "&"; + + mac.init(new SecretKeySpec(secret.getBytes("utf-8"), "HMAC-SHA1")); + String signature = Base64.encodeToString(mac.doFinal(string_to_sign.getBytes("utf-8")), 0).trim(); + params.add(new BasicNameValuePair("oauth_signature", signature)); + } catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return params; + } + + public ArrayList setParams(String endpoint, Map query) { + final String uri = baseUrl + endpoint; + + URI uri1 = URI.create(baseUrl + endpoint); + String urlString = ""; + try { + URL url = uri1.toURL(); + urlString = url.toString(); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + + oauth_nonce = getOauth_nonce(); + oauth_timestamp = getOauth_timestamp(); + + params = new ArrayList<>(); + + Iterator it = query.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry pair = (Map.Entry)it.next(); + params.add(new BasicNameValuePair((String) pair.getKey(), (String) pair.getValue())); + + it.remove(); + } + + params.add(new BasicNameValuePair("oauth_consumer_key", consumerKey)); + params.add(new BasicNameValuePair("oauth_nonce", oauth_nonce)); + params.add(new BasicNameValuePair("oauth_timestamp", oauth_timestamp)); + params.add(new BasicNameValuePair("oauth_signature_method", oauth_signature_method)); + + Collections.sort(params, new SortParams()); + + String encodedParams = URLEncodedUtils.format(params, "utf-8"); + + String string_to_sign = ""; + try { + string_to_sign = (new StringBuilder("GET&")).append(URLEncoder.encode(uri, "utf-8")).append("&").append(URLEncoder.encode(encodedParams, "utf-8")).toString(); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + + try { + Mac mac = Mac.getInstance("HMAC-SHA1"); + String secret = consumerSecret; + //if (API.WP_API_VERSION.equals("3")) { + secret = consumerSecret + "&"; + //} + mac.init(new SecretKeySpec(secret.getBytes("utf-8"), "HMAC-SHA1")); + String signature = Base64.encodeToString(mac.doFinal(string_to_sign.getBytes("utf-8")), 0).trim(); + params.add(new BasicNameValuePair("oauth_signature", signature)); + } catch (NoSuchAlgorithmException | InvalidKeyException | UnsupportedEncodingException e) { + e.printStackTrace(); + } + + return params; + } + + public static String getOauth_nonce() { + return (new StringBuilder(String.valueOf(Math.random() * 100000000D))).toString(); + } + + public static String getOauth_timestamp() { + long stamp = (long) (System.currentTimeMillis() / 1000D); + return (new StringBuilder(String.valueOf(stamp))).toString(); + } + + static class SortParams implements Comparator { + + @Override + public int compare(NameValuePair nameValuePair1, NameValuePair nameValuePair2) { + return nameValuePair1.getName().compareTo(nameValuePair2.getName()); + } + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/CategoriesCallback.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/CategoriesCallback.java new file mode 100644 index 0000000..6cc6dfa --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/CategoriesCallback.java @@ -0,0 +1,25 @@ +package me.gilo.woodroid.data.callbacks; + + +import com.google.gson.annotations.SerializedName; +import me.gilo.woodroid.models.Category; + + +import java.util.ArrayList; + + +/** + * Created by Aron on 12/8/2015. + */ +public class CategoriesCallback { + @SerializedName("product_categories") + ArrayList categories; + + public ArrayList getCategories() { + return categories; + } + + public void setCategories(ArrayList categories) { + this.categories = categories; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/CustomerData.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/CustomerData.java new file mode 100644 index 0000000..ec60f94 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/CustomerData.java @@ -0,0 +1,19 @@ +package me.gilo.woodroid.data.callbacks; + + +import me.gilo.woodroid.models.Customer; + +/** + * Created by Aron on 12/13/2015. + */ +public class CustomerData { + Customer customer; + + public Customer getCustomer() { + return customer; + } + + public void setCustomer(Customer customer) { + this.customer = customer; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/Data.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/Data.java new file mode 100644 index 0000000..9a7f357 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/Data.java @@ -0,0 +1,17 @@ +package me.gilo.woodroid.data.callbacks; +import me.gilo.woodroid.models.Order; + +/** + * Created by Aron on 12/12/2015. + */ +public class Data { + Order order; + + public Order getOrder() { + return order; + } + + public void setOrder(Order order) { + this.order = order; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/OrderCallback.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/OrderCallback.java new file mode 100644 index 0000000..a4aaff8 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/OrderCallback.java @@ -0,0 +1,21 @@ +package me.gilo.woodroid.data.callbacks; + + +import me.gilo.woodroid.models.Order; + +import java.util.ArrayList; + +/** + * Created by Aron on 12/7/2015. + */ +public class OrderCallback { + ArrayList orders = new ArrayList<>(); + + public ArrayList getOrders() { + return orders; + } + + public void setOrders(ArrayList orders) { + this.orders = orders; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ProductCallback.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ProductCallback.java new file mode 100644 index 0000000..ca27774 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ProductCallback.java @@ -0,0 +1,31 @@ +package me.gilo.woodroid.data.callbacks; + + +import me.gilo.woodroid.models.Product; + +import java.util.ArrayList; + + +/** + * Created by Aron on 11/10/2015. + */ +public class ProductCallback { + ArrayList products = new ArrayList<>(); + Product product; + + public ArrayList getProducts() { + return products; + } + + public void setProducts(ArrayList products) { + this.products = products; + } + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ProductData.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ProductData.java new file mode 100644 index 0000000..87578cd --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ProductData.java @@ -0,0 +1,19 @@ +package me.gilo.woodroid.data.callbacks; + + +import me.gilo.woodroid.models.Product; + +/** + * Created by Aron on 12/14/2015. + */ +public class ProductData { + private Product product; + + public Product getProduct() { + return product; + } + + public void setProduct(Product product) { + this.product = product; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ReviewsCallback.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ReviewsCallback.java new file mode 100644 index 0000000..564eb75 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ReviewsCallback.java @@ -0,0 +1,24 @@ +package me.gilo.woodroid.data.callbacks; + + +import com.google.gson.annotations.SerializedName; +import me.gilo.woodroid.models.ProductReview; + +import java.util.ArrayList; + + +/** + * Created by Aron on 12/8/2015. + */ +public class ReviewsCallback { + @SerializedName("product_reviews") + ArrayList productReviews; + + public ArrayList getProductReviews() { + return productReviews; + } + + public void setProductReviews(ArrayList productReviews) { + this.productReviews = productReviews; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ReviewsData.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ReviewsData.java new file mode 100644 index 0000000..e83315b --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/ReviewsData.java @@ -0,0 +1,21 @@ +package me.gilo.woodroid.data.callbacks; + + +import me.gilo.woodroid.models.ProductReview; + +import java.util.ArrayList; + +/** + * Created by Aron on 12/14/2015. + */ +public class ReviewsData { + ArrayList productReviews; + + public ArrayList getProductReviews() { + return productReviews; + } + + public void setProductReviews(ArrayList productReviews) { + this.productReviews = productReviews; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/StoreCallback.java b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/StoreCallback.java new file mode 100644 index 0000000..c1e8611 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/data/callbacks/StoreCallback.java @@ -0,0 +1,21 @@ +package me.gilo.woodroid.data.callbacks; + +import com.google.gson.annotations.SerializedName; +import me.gilo.woodroid.models.Store; + +/** + * Created by Aron on 2/20/2016. + */ +public class StoreCallback { + + @SerializedName("store") + Store store; + + public Store getStore() { + return store; + } + + public void setStore(Store store) { + this.store = store; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/models/Attribute.java b/woodroid/src/main/java/me/gilo/woodroid/models/Attribute.java new file mode 100644 index 0000000..f8aec18 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/models/Attribute.java @@ -0,0 +1,75 @@ +package me.gilo.woodroid.models; + +import android.os.Parcel; + +import java.io.Serializable; + +/** + * Created by Aron on 11/26/2015. + */ +public class Attribute implements Serializable { + private String name; + private String slug; + private int position; + private boolean visible; + private boolean variation; + private String[] options; + + protected Attribute(Parcel in) { + name = in.readString(); + slug = in.readString(); + position = in.readInt(); + visible = in.readByte() != 0; + variation = in.readByte() != 0; + options = in.createStringArray(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getSlug() { + return slug; + } + + public void setSlug(String slug) { + this.slug = slug; + } + + public int getPosition() { + return position; + } + + public void setPosition(int position) { + this.position = position; + } + + public boolean isVisible() { + return visible; + } + + public void setVisible(boolean visible) { + this.visible = visible; + } + + public boolean isVariation() { + return variation; + } + + public void setVariation(boolean variation) { + this.variation = variation; + } + + public String[] getOptions() { + return options; + } + + public void setOptions(String[] options) { + this.options = options; + } + +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/models/BillingAddress.java b/woodroid/src/main/java/me/gilo/woodroid/models/BillingAddress.java new file mode 100644 index 0000000..e7f111f --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/models/BillingAddress.java @@ -0,0 +1,123 @@ +package me.gilo.woodroid.models; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +/** + * Created by Aron on 12/7/2015. + */ +public class BillingAddress implements Serializable{ + public int id; + @SerializedName("first_name") + public String firstName; + @SerializedName("last_name") + public String lastName; + public String company; + @SerializedName("address_1") + public String address1; + @SerializedName("address_2") + public String address2; + public String city; + public String state; + public String postcode; + public String country; + public String email; + public String phone; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getCompany() { + return company; + } + + public void setCompany(String company) { + this.company = company; + } + + public String getAddress1() { + return address1; + } + + public void setAddress1(String address1) { + this.address1 = address1; + } + + public String getAddress2() { + return address2; + } + + public void setAddress2(String address2) { + this.address2 = address2; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getState() { + return state; + } + + public void setState(String state) { + this.state = state; + } + + public String getPostcode() { + return postcode; + } + + public void setPostcode(String postcode) { + this.postcode = postcode; + } + + public String getCountry() { + return country; + } + + public void setCountry(String country) { + this.country = country; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getPhone() { + return phone; + } + + public void setPhone(String phone) { + this.phone = phone; + } +} diff --git a/woodroid/src/main/java/me/gilo/woodroid/models/CartItem.java b/woodroid/src/main/java/me/gilo/woodroid/models/CartItem.java new file mode 100644 index 0000000..d83bbc6 --- /dev/null +++ b/woodroid/src/main/java/me/gilo/woodroid/models/CartItem.java @@ -0,0 +1,36 @@ +package me.gilo.woodroid.models; + +import java.util.ArrayList; + +/** + * Created by gilo on 2/18/16. + */ +public class CartItem { + Product product; + ArrayList