├── .gitignore
├── .idea
├── codeStyles
│ └── Project.xml
├── encodings.xml
├── libraries
│ ├── Dart_SDK.xml
│ └── Flutter_Plugins.xml
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── android
├── .gitignore
├── .idea
│ └── modules.xml
├── build.gradle
├── gradle.properties
├── gradle
│ └── wrapper
│ │ ├── gradle-wrapper.jar
│ │ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── library
│ ├── gateway
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── shopapp
│ │ │ │ └── gateway
│ │ │ │ ├── Api.kt
│ │ │ │ ├── ApiCallback.kt
│ │ │ │ └── entity
│ │ │ │ ├── Address.kt
│ │ │ │ ├── Article.kt
│ │ │ │ ├── Author.kt
│ │ │ │ ├── Card.kt
│ │ │ │ ├── CardType.kt
│ │ │ │ ├── CartProduct.kt
│ │ │ │ ├── Category.kt
│ │ │ │ ├── Checkout.kt
│ │ │ │ ├── Country.kt
│ │ │ │ ├── Customer.kt
│ │ │ │ ├── Error.kt
│ │ │ │ ├── Image.kt
│ │ │ │ ├── Order.kt
│ │ │ │ ├── OrderProduct.kt
│ │ │ │ ├── Policy.kt
│ │ │ │ ├── Product.kt
│ │ │ │ ├── ProductOption.kt
│ │ │ │ ├── ProductVariant.kt
│ │ │ │ ├── ShippingRate.kt
│ │ │ │ ├── Shop.kt
│ │ │ │ ├── SortType.kt
│ │ │ │ ├── State.kt
│ │ │ │ └── VariantOption.kt
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ ├── ic_amex.xml
│ │ │ ├── ic_dc_card.xml
│ │ │ ├── ic_discover.xml
│ │ │ ├── ic_jcb_card.xml
│ │ │ ├── ic_master_card.xml
│ │ │ └── ic_visa.xml
│ │ │ └── values
│ │ │ └── strings.xml
│ └── shopifylibrary
│ │ ├── .gitignore
│ │ ├── build.gradle
│ │ ├── proguard-rules.pro
│ │ └── src
│ │ ├── main
│ │ ├── AndroidManifest.xml
│ │ ├── assets
│ │ │ └── countries.json
│ │ └── java
│ │ │ └── com
│ │ │ └── shopapp
│ │ │ └── shopify
│ │ │ ├── api
│ │ │ ├── QueryHelper.kt
│ │ │ ├── ShopifyApi.kt
│ │ │ ├── adapter
│ │ │ │ ├── AddressAdapter.kt
│ │ │ │ ├── ArticleAdapter.kt
│ │ │ │ ├── ArticleListAdapter.kt
│ │ │ │ ├── AuthorAdapter.kt
│ │ │ │ ├── CardAdapter.kt
│ │ │ │ ├── CategoryAdapter.kt
│ │ │ │ ├── CategoryListAdapter.kt
│ │ │ │ ├── CheckoutAdapter.kt
│ │ │ │ ├── CountryAdapter.kt
│ │ │ │ ├── CountryListAdapter.kt
│ │ │ │ ├── CustomerAdapter.kt
│ │ │ │ ├── ErrorAdapter.kt
│ │ │ │ ├── ImageAdapter.kt
│ │ │ │ ├── OrderAdapter.kt
│ │ │ │ ├── OrderListAdapter.kt
│ │ │ │ ├── OrderProductAdapter.kt
│ │ │ │ ├── PolicyAdapter.kt
│ │ │ │ ├── ProductAdapter.kt
│ │ │ │ ├── ProductListAdapter.kt
│ │ │ │ ├── ProductOptionListAdapter.kt
│ │ │ │ ├── ProductVariantAdapter.kt
│ │ │ │ ├── ShippingRateAdapter.kt
│ │ │ │ ├── ShopAdapter.kt
│ │ │ │ ├── StateAdapter.kt
│ │ │ │ ├── StateListAdapter.kt
│ │ │ │ └── VariantOptionListAdapter.kt
│ │ │ ├── call
│ │ │ │ ├── AdapterResult.kt
│ │ │ │ ├── MutationCallWrapper.kt
│ │ │ │ └── QueryCallWrapper.kt
│ │ │ ├── entity
│ │ │ │ ├── AccessData.kt
│ │ │ │ ├── ApiCountry.kt
│ │ │ │ ├── ApiCountryResponse.kt
│ │ │ │ └── ApiState.kt
│ │ │ ├── ext
│ │ │ │ └── ProductExtension.kt
│ │ │ └── retrofit
│ │ │ │ ├── CountriesService.kt
│ │ │ │ └── RestClient.kt
│ │ │ ├── constant
│ │ │ └── Constant.kt
│ │ │ └── util
│ │ │ └── AssetsReader.kt
│ │ └── test
│ │ ├── java
│ │ └── com
│ │ │ └── shopapp
│ │ │ └── shopify
│ │ │ ├── JodaTimeAndroidRule.kt
│ │ │ ├── StorefrontMockInstantiator.kt
│ │ │ ├── api
│ │ │ ├── BaseShopifyApiTest.kt
│ │ │ ├── ShopifyApiAuthTest.kt
│ │ │ ├── ShopifyApiBlogTest.kt
│ │ │ ├── ShopifyApiCategoryTest.kt
│ │ │ ├── ShopifyApiCheckoutTest.kt
│ │ │ ├── ShopifyApiOrderTest.kt
│ │ │ ├── ShopifyApiProductTest.kt
│ │ │ ├── ShopifyApiShopTest.kt
│ │ │ ├── adapter
│ │ │ │ ├── AddressAdapterTest.kt
│ │ │ │ ├── ArticleAdapterTest.kt
│ │ │ │ ├── ArticleListAdapterTest.kt
│ │ │ │ ├── AuthorAdapterTest.kt
│ │ │ │ ├── CardAdapterTest.kt
│ │ │ │ ├── CategoryAdapterTest.kt
│ │ │ │ ├── CategoryListAdapterTest.kt
│ │ │ │ ├── CheckoutAdapterTest.kt
│ │ │ │ ├── CountryAdapterTest.kt
│ │ │ │ ├── CountryListAdapterTest.kt
│ │ │ │ ├── CustomerAdapterTest.kt
│ │ │ │ ├── ErrorAdapterTest.kt
│ │ │ │ ├── ImageAdapterTest.kt
│ │ │ │ ├── OrderAdapterTest.kt
│ │ │ │ ├── OrderListAdapterTest.kt
│ │ │ │ ├── OrderProductAdapterTest.kt
│ │ │ │ ├── PolicyAdapterTest.kt
│ │ │ │ ├── ProductAdapterTest.kt
│ │ │ │ ├── ProductListAdapterTest.kt
│ │ │ │ ├── ProductOptionListAdapterTest.kt
│ │ │ │ ├── ProductVariantAdapterTest.kt
│ │ │ │ ├── ShippingRateAdapterTest.kt
│ │ │ │ ├── ShopAdapterTest.kt
│ │ │ │ ├── StateAdapterTest.kt
│ │ │ │ ├── StateListAdapterTest.kt
│ │ │ │ └── VariantOptionListAdapterTest.kt
│ │ │ └── call
│ │ │ │ ├── MutationCallWrapperTest.kt
│ │ │ │ └── QueryCallWrapperTest.kt
│ │ │ └── ext
│ │ │ └── ProductExtensionTest.kt
│ │ └── resources
│ │ └── mockito-extensions
│ │ └── org.mockito.plugins.MockMaker
├── settings.gradle
└── src
│ └── main
│ ├── AndroidManifest.xml
│ └── java
│ └── com
│ └── jvanila
│ └── flutter
│ ├── plugin
│ └── arch
│ │ ├── Plugin.java
│ │ ├── PluginContext.java
│ │ ├── UseCase.java
│ │ ├── UseCaseProvider.java
│ │ └── UseCaseResult.java
│ └── shopify
│ ├── Api.java
│ ├── ShopifyConstants.java
│ ├── ShopifyPlugin.java
│ └── usecases
│ ├── ChangePasswordUseCase.java
│ ├── CompleteCheckoutByCardUseCase.java
│ ├── CreateCheckoutUseCase.java
│ ├── CreateCustomerAddressUseCase.java
│ ├── DeleteCustomerAddressUseCase.java
│ ├── EditCustomerAddressUseCase.java
│ ├── EditCustomerInfoUseCase.java
│ ├── ForgotPasswordUseCase.java
│ ├── GetAcceptedCardTypesUseCase.java
│ ├── GetAccessTokenUseCase.java
│ ├── GetArticleListUseCase.java
│ ├── GetArticleUseCase.java
│ ├── GetCardTokenUseCase.java
│ ├── GetCategoryDetailsUseCase.java
│ ├── GetCategoryListUseCase.java
│ ├── GetCheckoutUseCase.java
│ ├── GetCountriesUseCase.java
│ ├── GetCustomerUseCase.java
│ ├── GetOrderUseCase.java
│ ├── GetOrdersUseCase.java
│ ├── GetProductListUseCase.java
│ ├── GetProductUseCase.java
│ ├── GetProductVariantListUseCase.java
│ ├── GetShippingRatesUseCase.java
│ ├── GetShopInfoUseCase.java
│ ├── InitializeUseCase.java
│ ├── IsLoggedInUseCase.java
│ ├── SearchProductListUseCase.java
│ ├── SelectShippingRateUseCase.java
│ ├── SetDefaultShippingAddressUseCase.java
│ ├── SetShippingAddressUseCase.java
│ ├── ShopifyCallUseCase.java
│ ├── SignInUseCase.java
│ ├── SignOutUseCase.java
│ ├── SignUpUseCase.java
│ └── UpdateCustomerSettingsUseCase.java
├── example
├── .gitignore
├── .idea
│ └── modules.xml
├── README.md
├── android
│ ├── .gitignore
│ ├── .idea
│ │ ├── caches
│ │ │ └── build_file_checksums.ser
│ │ ├── encodings.xml
│ │ ├── gradle.xml
│ │ ├── misc.xml
│ │ ├── modules.xml
│ │ ├── runConfigurations.xml
│ │ └── vcs.xml
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ └── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── java
│ │ │ └── com
│ │ │ │ └── jvanila
│ │ │ │ └── shopifyexample
│ │ │ │ └── MainActivity.java
│ │ │ └── res
│ │ │ ├── drawable
│ │ │ └── launch_background.xml
│ │ │ ├── mipmap-hdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-mdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── mipmap-xxxhdpi
│ │ │ └── ic_launcher.png
│ │ │ ├── values
│ │ │ └── styles.xml
│ │ │ └── xml
│ │ │ └── network_security_config.xml
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── ios
│ ├── .gitignore
│ ├── Flutter
│ │ ├── AppFrameworkInfo.plist
│ │ ├── Debug.xcconfig
│ │ └── Release.xcconfig
│ ├── Podfile
│ ├── Runner.xcodeproj
│ │ ├── project.pbxproj
│ │ ├── project.xcworkspace
│ │ │ └── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ └── xcschemes
│ │ │ └── Runner.xcscheme
│ ├── Runner.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── Runner
│ │ ├── AppDelegate.h
│ │ ├── AppDelegate.m
│ │ ├── Assets.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── Contents.json
│ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ ├── Icon-App-20x20@1x.png
│ │ │ ├── Icon-App-20x20@2x.png
│ │ │ ├── Icon-App-20x20@3x.png
│ │ │ ├── Icon-App-29x29@1x.png
│ │ │ ├── Icon-App-29x29@2x.png
│ │ │ ├── Icon-App-29x29@3x.png
│ │ │ ├── Icon-App-40x40@1x.png
│ │ │ ├── Icon-App-40x40@2x.png
│ │ │ ├── Icon-App-40x40@3x.png
│ │ │ ├── Icon-App-60x60@2x.png
│ │ │ ├── Icon-App-60x60@3x.png
│ │ │ ├── Icon-App-76x76@1x.png
│ │ │ ├── Icon-App-76x76@2x.png
│ │ │ └── Icon-App-83.5x83.5@2x.png
│ │ └── LaunchImage.imageset
│ │ │ ├── Contents.json
│ │ │ ├── LaunchImage.png
│ │ │ ├── LaunchImage@2x.png
│ │ │ ├── LaunchImage@3x.png
│ │ │ └── README.md
│ │ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ │ ├── HelloSwift.swift
│ │ ├── Info.plist
│ │ ├── Runner-Bridging-Header.h
│ │ └── main.m
├── lib
│ ├── LoadMore_Listview.dart
│ ├── app.dart
│ ├── application.dart
│ ├── listView_main.dart
│ ├── main.dart
│ ├── tow_injector.dart
│ ├── web_view.dart
│ ├── web_view_presenter.dart
│ ├── webview_main.dart
│ └── webview_widget.dart
├── pubspec.yaml
├── shopify_example.iml
├── shopify_example_android.iml
└── test
│ └── widget_test.dart
├── ios
├── .gitignore
├── Assets
│ └── .gitkeep
├── Classes
│ ├── ShopifyConstants.h
│ ├── ShopifyPlugin.h
│ ├── ShopifyPlugin.m
│ ├── UseCases
│ │ ├── ClosePluginUseCase.h
│ │ ├── ClosePluginUseCase.m
│ │ ├── GetPlatformVersionUseCase.h
│ │ └── GetPlatformVersionUseCase.m
│ └── jVanila
│ │ ├── Api.h
│ │ ├── Api.m
│ │ ├── Plugin.h
│ │ ├── Plugin.m
│ │ ├── PluginContext.h
│ │ ├── PluginContext.m
│ │ ├── UseCase.h
│ │ ├── UseCase.m
│ │ ├── UseCaseProvider.h
│ │ └── UseCaseProvider.m
└── shopify.podspec
├── lib
├── domain
│ └── initialize_params.dart
├── model
│ ├── address.dart
│ ├── address.g.dart
│ ├── article.dart
│ ├── article.g.dart
│ ├── author.dart
│ ├── author.g.dart
│ ├── card.dart
│ ├── card_type.dart
│ ├── cart_product.dart
│ ├── cart_product.g.dart
│ ├── category.dart
│ ├── category.g.dart
│ ├── checkout.dart
│ ├── checkout.g.dart
│ ├── country.dart
│ ├── country.g.dart
│ ├── customer.dart
│ ├── customer.g.dart
│ ├── delivery_info.dart
│ ├── error.dart
│ ├── image.dart
│ ├── image.g.dart
│ ├── offer_product.dart
│ ├── order.dart
│ ├── order.g.dart
│ ├── order_product.dart
│ ├── order_product.g.dart
│ ├── policy.dart
│ ├── policy.g.dart
│ ├── product.dart
│ ├── product.g.dart
│ ├── product_option.dart
│ ├── product_option.g.dart
│ ├── product_variant.dart
│ ├── product_variant.g.dart
│ ├── shipping_rate.dart
│ ├── shipping_rate.g.dart
│ ├── shop.dart
│ ├── shop.g.dart
│ ├── sort_type.dart
│ ├── state.dart
│ ├── state.g.dart
│ ├── store.dart
│ ├── variant_option.dart
│ └── variant_option.g.dart
├── shopify.dart
├── shopify_constants.dart
└── stopwatch.dart
├── pubspec.yaml
├── shopify.iml
└── shopify_android.iml
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 | pubspec.lock
7 |
8 | build/
9 |
--------------------------------------------------------------------------------
/.idea/codeStyles/Project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/libraries/Flutter_Plugins.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | ## 0.0.1
2 |
3 | * TODO: Describe initial release.
4 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | TODO: Add your license here.
2 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # shopify
2 |
3 | A new Flutter plugin.
4 |
5 | ## Getting Started
6 |
7 | For help getting started with Flutter, view our online
8 | [documentation](https://flutter.io/).
9 |
10 | For help on editing plugin code, view the [documentation](https://flutter.io/platform-plugins/#edit-code).
--------------------------------------------------------------------------------
/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 |
--------------------------------------------------------------------------------
/android/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/android/build.gradle:
--------------------------------------------------------------------------------
1 | group 'com.jvanila.flutter.shopify'
2 | version '1.0-SNAPSHOT'
3 |
4 | buildscript {
5 | repositories {
6 | google()
7 | jcenter()
8 | maven { url 'https://maven.fabric.io/public' }
9 | }
10 |
11 | dependencies {
12 | classpath 'com.android.tools.build:gradle:3.4.2'
13 | classpath 'io.fabric.tools:gradle:1.+'
14 | classpath 'com.github.dcendents:android-maven-gradle-plugin:2.0'
15 | }
16 | }
17 |
18 | rootProject.allprojects {
19 | repositories {
20 | google()
21 | jcenter()
22 | maven { url "https://jitpack.io" }
23 | maven { url 'https://maven.fabric.io/public' }
24 | }
25 | }
26 |
27 | apply plugin: 'com.android.library'
28 |
29 | android {
30 | compileSdkVersion 28
31 |
32 | defaultConfig {
33 | minSdkVersion 19
34 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
35 | }
36 | lintOptions {
37 | disable 'InvalidPackage'
38 | }
39 | compileOptions {
40 | sourceCompatibility JavaVersion.VERSION_1_8
41 | targetCompatibility JavaVersion.VERSION_1_8
42 | }
43 | }
44 |
45 | dependencies {
46 | implementation fileTree(include: ['*.jar'], dir: 'libs')
47 | implementation 'androidx.multidex:multidex:2.0.0'
48 | implementation 'com.google.code.gson:gson:2.8.2'
49 | implementation 'androidx.annotation:annotation:1.0.0'
50 | implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.31'
51 | implementation project(':shopifylibrary')
52 | }
53 |
--------------------------------------------------------------------------------
/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | # Disables R8 for all modules.
3 | android.enableR8 = false
4 |
5 | android.useAndroidX=true
6 | android.enableJetifier=true
7 |
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Thu Aug 30 11:34:28 IST 2018
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
7 |
--------------------------------------------------------------------------------
/android/library/gateway/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android/library/gateway/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'kotlin-android'
3 | apply plugin: 'com.github.dcendents.android-maven'
4 |
5 | group='com.github.rubygarage'
6 |
7 | android {
8 | def globalConfiguration = rootProject.extensions.getByName("ext")
9 | compileSdkVersion globalConfiguration["androidCompileSdkVersion"]
10 | defaultConfig {
11 | minSdkVersion globalConfiguration["androidMinSdkVersion"]
12 | targetSdkVersion globalConfiguration["androidTargetSdkVersion"]
13 | versionCode 1
14 | versionName globalConfiguration["versionName"]
15 |
16 | testInstrumentationRunner globalConfiguration["testInstrumentationRunner"]
17 | }
18 | buildTypes {
19 | profile {
20 | debuggable true
21 | jniDebuggable false
22 | }
23 | }
24 | compileOptions {
25 | sourceCompatibility JavaVersion.VERSION_1_8
26 | targetCompatibility JavaVersion.VERSION_1_8
27 | }
28 | }
29 |
30 | dependencies {
31 | implementation fileTree(include: ['*.jar'], dir: 'libs')
32 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlinVersion"
33 | testImplementation "junit:junit:$junitVersion"
34 | androidTestImplementation "com.android.support.test:runner:$testRunnerVersion"
35 | }
36 |
37 | // build a jar with source files
38 | task sourcesJar(type: Jar) {
39 | from android.sourceSets.main.java.srcDirs
40 | classifier = 'sources'
41 | }
42 |
43 | task javadoc(type: Javadoc) {
44 | failOnError false
45 | source = android.sourceSets.main.java.sourceFiles
46 | classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
47 | classpath += configurations.compile
48 | }
49 |
50 | // build a jar with javadoc
51 | task javadocJar(type: Jar, dependsOn: javadoc) {
52 | classifier = 'javadoc'
53 | from javadoc.destinationDir
54 | }
55 |
56 | artifacts {
57 | archives sourcesJar
58 | archives javadocJar
59 | }
--------------------------------------------------------------------------------
/android/library/gateway/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/ApiCallback.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway
2 |
3 | import com.shopapp.gateway.entity.Error
4 |
5 | interface ApiCallback {
6 |
7 | fun onResult(result: T)
8 |
9 | fun onFailure(error: Error)
10 | }
11 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Author.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class Author(var firstName: String,
7 | var lastName: String,
8 | var fullName: String,
9 | var email: String,
10 | var bio: String?
11 | ) : Parcelable {
12 |
13 | constructor(source: Parcel) : this(
14 | source.readString(),
15 | source.readString(),
16 | source.readString(),
17 | source.readString(),
18 | source.readString()
19 | )
20 |
21 | override fun describeContents() = 0
22 |
23 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
24 | writeString(firstName)
25 | writeString(lastName)
26 | writeString(fullName)
27 | writeString(email)
28 | writeString(bio)
29 | }
30 |
31 | companion object {
32 | @JvmField
33 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
34 | override fun createFromParcel(source: Parcel): Author = Author(source)
35 | override fun newArray(size: Int): Array = arrayOfNulls(size)
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Card.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class Card(
7 | val firstName: String,
8 | val lastName: String,
9 | val cardNumber: String,
10 | val expireMonth: String,
11 | val expireYear: String,
12 | val verificationCode: String
13 | ) : Parcelable {
14 |
15 | constructor(source: Parcel) : this(
16 | source.readString(),
17 | source.readString(),
18 | source.readString(),
19 | source.readString(),
20 | source.readString(),
21 | source.readString()
22 | )
23 |
24 | override fun describeContents() = 0
25 |
26 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
27 | writeString(firstName)
28 | writeString(lastName)
29 | writeString(cardNumber)
30 | writeString(expireMonth)
31 | writeString(expireYear)
32 | writeString(verificationCode)
33 | }
34 |
35 | companion object {
36 | @JvmField
37 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
38 | override fun createFromParcel(source: Parcel): Card = Card(source)
39 | override fun newArray(size: Int): Array = arrayOfNulls(size)
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/CardType.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import com.shopapp.gateway.R
4 |
5 |
6 | enum class CardType(val nameRes: Int, val logoRes: Int) {
7 | VISA(R.string.visa, R.drawable.ic_visa),
8 | MASTER_CARD(R.string.mastercard, R.drawable.ic_master_card),
9 | AMERICAN_EXPRESS(R.string.american_express, R.drawable.ic_amex),
10 | DINERS_CLUB(R.string.diners_club, R.drawable.ic_dc_card),
11 | DISCOVER(R.string.discover, R.drawable.ic_discover),
12 | JCB(R.string.jcb, R.drawable.ic_jcb_card)
13 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/CartProduct.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | data class CartProduct(
4 | val productVariant: ProductVariant,
5 | val title: String,
6 | val currency: String,
7 | val quantity: Int
8 | )
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Category.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 | import java.util.*
6 |
7 | data class Category(var id: String,
8 | var title: String,
9 | var categoryDescription: String,
10 | var additionalDescription: String,
11 | var image: Image?,
12 | var updatedAt: Date,
13 | var productList: List,
14 | var paginationValue: String? = null
15 | ) : Parcelable {
16 |
17 | constructor(source: Parcel) : this(
18 | source.readString(),
19 | source.readString(),
20 | source.readString(),
21 | source.readString(),
22 | source.readParcelable(Image::class.java.classLoader),
23 | source.readSerializable() as Date,
24 | source.createTypedArrayList(Product.CREATOR),
25 | source.readString()
26 | )
27 |
28 | override fun describeContents() = 0
29 |
30 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
31 | writeString(id)
32 | writeString(title)
33 | writeString(categoryDescription)
34 | writeString(additionalDescription)
35 | writeParcelable(image, 0)
36 | writeSerializable(updatedAt)
37 | writeTypedList(productList)
38 | writeString(paginationValue)
39 | }
40 |
41 | companion object {
42 | @JvmField
43 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
44 | override fun createFromParcel(source: Parcel): Category = Category(source)
45 | override fun newArray(size: Int): Array = arrayOfNulls(size)
46 | }
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Checkout.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import java.math.BigDecimal
4 |
5 | data class Checkout(
6 | val checkoutId: String,
7 | val webUrl: String,
8 | val requiresShipping: Boolean,
9 | val subtotalPrice: BigDecimal,
10 | val totalPrice: BigDecimal,
11 | val taxPrice: BigDecimal,
12 | val currency: String,
13 | val address: Address?,
14 | val shippingRate: ShippingRate?
15 | )
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Country.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class Country(
7 | val id: Long,
8 | val code: String,
9 | val name: String,
10 | val states: List?
11 | ) : Parcelable {
12 |
13 | constructor(source: Parcel) : this(
14 | source.readLong(),
15 | source.readString(),
16 | source.readString(),
17 | source.createTypedArrayList(State.CREATOR)
18 | )
19 |
20 | override fun describeContents() = 0
21 |
22 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
23 | writeLong(id)
24 | writeString(code)
25 | writeString(name)
26 | writeTypedList(states)
27 | }
28 |
29 | companion object {
30 | @JvmField
31 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
32 | override fun createFromParcel(source: Parcel): Country = Country(source)
33 | override fun newArray(size: Int): Array = arrayOfNulls(size)
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Customer.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | data class Customer(
4 | val id: String,
5 | val email: String,
6 | val firstName: String,
7 | val lastName: String,
8 | var phone: String,
9 | var isAcceptsMarketing: Boolean,
10 | val addressList: List,
11 | val defaultAddress: Address?
12 | )
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Error.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | sealed class Error : Exception() {
4 | class Critical : Error()
5 | class NonCritical(override val message: String) : Error()
6 | class Content(var isNetworkError: Boolean = false) : Error()
7 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Image.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class Image(var id: String,
7 | var src: String,
8 | var alt: String?
9 | ) : Parcelable {
10 |
11 | constructor(source: Parcel) : this(
12 | source.readString(),
13 | source.readString(),
14 | source.readString()
15 | )
16 |
17 | override fun describeContents() = 0
18 |
19 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
20 | writeString(id)
21 | writeString(src)
22 | writeString(alt)
23 | }
24 |
25 | companion object {
26 | @JvmField
27 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
28 | override fun createFromParcel(source: Parcel): Image = Image(source)
29 | override fun newArray(size: Int): Array = arrayOfNulls(size)
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Order.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import java.math.BigDecimal
4 | import java.util.*
5 |
6 | data class Order(
7 | val id: String,
8 | val currency: String,
9 | val email: String,
10 | val orderNumber: Int,
11 | val subtotalPrice: BigDecimal?,
12 | val totalShippingPrice: BigDecimal?,
13 | val totalPrice: BigDecimal,
14 | val processedAt: Date,
15 | val orderProducts: List,
16 | val address: Address?,
17 | val paginationValue: String? = null
18 | )
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/OrderProduct.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | data class OrderProduct(
4 | val title: String,
5 | val productVariant: ProductVariant?,
6 | val quantity: Int
7 | )
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Policy.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class Policy(var title: String,
7 | var body: String,
8 | var url: String
9 | ) : Parcelable {
10 |
11 | constructor(source: Parcel) : this(
12 | source.readString(),
13 | source.readString(),
14 | source.readString()
15 | )
16 |
17 | override fun describeContents() = 0
18 |
19 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
20 | writeString(title)
21 | writeString(body)
22 | writeString(url)
23 | }
24 |
25 | companion object {
26 | @JvmField
27 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
28 | override fun createFromParcel(source: Parcel): Policy = Policy(source)
29 | override fun newArray(size: Int): Array = arrayOfNulls(size)
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/ProductOption.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class ProductOption(var id: String,
7 | var name: String,
8 | var values: List
9 | ) : Parcelable {
10 |
11 | constructor(source: Parcel) : this(
12 | source.readString(),
13 | source.readString(),
14 | source.createStringArrayList()
15 | )
16 |
17 | override fun describeContents() = 0
18 |
19 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
20 | writeString(id)
21 | writeString(name)
22 | writeStringList(values)
23 | }
24 |
25 | companion object {
26 | @JvmField
27 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
28 | override fun createFromParcel(source: Parcel): ProductOption = ProductOption(source)
29 | override fun newArray(size: Int): Array = arrayOfNulls(size)
30 | }
31 | }
32 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/ProductVariant.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 | import java.math.BigDecimal
6 |
7 | data class ProductVariant(
8 | var id: String,
9 | var title: String,
10 | var price: BigDecimal,
11 | var compareAtPrice: BigDecimal,
12 | var isAvailable: Boolean,
13 | var selectedOptions: List,
14 | var image: Image? = null,
15 | var productImage: Image? = null,
16 | var productId: String
17 | ) : Parcelable {
18 |
19 | constructor(source: Parcel) : this(
20 | source.readString(),
21 | source.readString(),
22 | source.readSerializable() as BigDecimal,
23 | source.readSerializable() as BigDecimal,
24 | 1 == source.readInt(),
25 | source.createTypedArrayList(VariantOption.CREATOR),
26 | source.readParcelable(Image::class.java.classLoader),
27 | source.readParcelable(Image::class.java.classLoader),
28 | source.readString()
29 | )
30 |
31 | override fun describeContents() = 0
32 |
33 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
34 | writeString(id)
35 | writeString(title)
36 | writeSerializable(price)
37 | writeSerializable(compareAtPrice)
38 | writeInt((if (isAvailable) 1 else 0))
39 | writeTypedList(selectedOptions)
40 | writeParcelable(image, 0)
41 | writeParcelable(productImage, 0)
42 | writeString(productId)
43 | }
44 |
45 | companion object {
46 | @JvmField
47 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
48 | override fun createFromParcel(source: Parcel): ProductVariant = ProductVariant(source)
49 | override fun newArray(size: Int): Array = arrayOfNulls(size)
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/ShippingRate.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import java.math.BigDecimal
4 |
5 | data class ShippingRate(
6 | val title: String,
7 | val price: BigDecimal,
8 | val handle: String
9 | )
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/Shop.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class Shop(var name: String,
7 | var description: String?,
8 | var privacyPolicy: Policy?,
9 | var refundPolicy: Policy?,
10 | var termsOfService: Policy?
11 | ) : Parcelable {
12 |
13 | constructor(source: Parcel) : this(
14 | source.readString(),
15 | source.readString(),
16 | source.readParcelable(Policy::class.java.classLoader),
17 | source.readParcelable(Policy::class.java.classLoader),
18 | source.readParcelable(Policy::class.java.classLoader)
19 | )
20 |
21 | override fun describeContents() = 0
22 |
23 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
24 | writeString(name)
25 | writeString(description)
26 | writeParcelable(privacyPolicy, 0)
27 | writeParcelable(refundPolicy, 0)
28 | writeParcelable(termsOfService, 0)
29 | }
30 |
31 | companion object {
32 | @JvmField
33 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
34 | override fun createFromParcel(source: Parcel): Shop = Shop(source)
35 | override fun newArray(size: Int): Array = arrayOfNulls(size)
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/SortType.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | enum class SortType {
4 | NAME(),
5 | RECENT(),
6 | RELEVANT(),
7 | TYPE(),
8 | PRICE_HIGH_TO_LOW(),
9 | PRICE_LOW_TO_HIGH();
10 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/State.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class State(
7 | val id: Long,
8 | val countryId: Long,
9 | val code: String,
10 | val name: String
11 | ) : Parcelable {
12 |
13 | constructor(source: Parcel) : this(
14 | source.readLong(),
15 | source.readLong(),
16 | source.readString(),
17 | source.readString()
18 | )
19 |
20 | override fun describeContents() = 0
21 |
22 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
23 | writeLong(id)
24 | writeLong(countryId)
25 | writeString(code)
26 | writeString(name)
27 | }
28 |
29 | companion object {
30 | @JvmField
31 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
32 | override fun createFromParcel(source: Parcel): State = State(source)
33 | override fun newArray(size: Int): Array = arrayOfNulls(size)
34 | }
35 | }
36 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/java/com/shopapp/gateway/entity/VariantOption.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.gateway.entity
2 |
3 | import android.os.Parcel
4 | import android.os.Parcelable
5 |
6 | data class VariantOption(var name: String, var value: String) : Parcelable {
7 |
8 | constructor(source: Parcel) : this(
9 | source.readString(),
10 | source.readString()
11 | )
12 |
13 | override fun describeContents() = 0
14 |
15 | override fun writeToParcel(dest: Parcel, flags: Int) = with(dest) {
16 | writeString(name)
17 | writeString(value)
18 | }
19 |
20 | companion object {
21 | @JvmField
22 | val CREATOR: Parcelable.Creator = object : Parcelable.Creator {
23 | override fun createFromParcel(source: Parcel): VariantOption = VariantOption(source)
24 | override fun newArray(size: Int): Array = arrayOfNulls(size)
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/android/library/gateway/src/main/res/drawable/ic_amex.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
16 |
17 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/res/drawable/ic_dc_card.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
16 |
17 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/res/drawable/ic_jcb_card.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
16 |
21 |
26 |
27 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/res/drawable/ic_master_card.xml:
--------------------------------------------------------------------------------
1 |
6 |
11 |
16 |
21 |
26 |
27 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/res/drawable/ic_visa.xml:
--------------------------------------------------------------------------------
1 |
7 |
12 |
18 |
19 |
--------------------------------------------------------------------------------
/android/library/gateway/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | Visa
3 | Mastercard
4 | American Express
5 | Diners Club
6 | Discover
7 | JCB
8 | China UnionPay
9 |
10 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
22 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/AddressAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Address
4 | import com.shopapp.shopify.constant.Constant
5 | import com.shopify.buy3.Storefront
6 |
7 | object AddressAdapter {
8 |
9 | fun adapt(adaptee: Storefront.MailingAddress): Address {
10 | return Address(
11 | id = adaptee.id.toString(),
12 | address = adaptee.address1,
13 | secondAddress = adaptee.address2,
14 | city = adaptee.city,
15 | state = adaptee.province,
16 | country = adaptee.country,
17 | firstName = adaptee.firstName,
18 | lastName = adaptee.lastName,
19 | zip = adaptee.zip ?: Constant.DEFAULT_STRING,
20 | company = adaptee.company ?: Constant.DEFAULT_STRING,
21 | phone = adaptee.phone
22 | )
23 | }
24 |
25 | fun adapt(adaptee: Storefront.MailingAddressConnection?): List {
26 | return adaptee?.edges?.map { adapt(it.node) } ?: listOf()
27 | }
28 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ArticleAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Article
4 | import com.shopify.buy3.Storefront
5 |
6 | object ArticleAdapter {
7 |
8 | fun adapt(adaptee: Storefront.Article, paginationValue: String? = null): Article {
9 | return Article(
10 | adaptee.id.toString(),
11 | adaptee.title,
12 | adaptee.content,
13 | adaptee.contentHtml,
14 | ImageAdapter.adapt(adaptee.image),
15 | AuthorAdapter.adapt(adaptee.author),
16 | adaptee.tags,
17 | adaptee.blog.id.toString(),
18 | adaptee.blog.title,
19 | adaptee.publishedAt.toDate(),
20 | adaptee.url,
21 | paginationValue)
22 | }
23 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ArticleListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Article
4 | import com.shopify.buy3.Storefront
5 |
6 | object ArticleListAdapter {
7 |
8 | fun adapt(edges: List): List =
9 | edges.map { ArticleAdapter.adapt(it.node, it.cursor) }
10 | }
11 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/AuthorAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Author
4 | import com.shopify.buy3.Storefront
5 |
6 | object AuthorAdapter {
7 |
8 | fun adapt(adaptee: Storefront.ArticleAuthor): Author {
9 | return Author(
10 | adaptee.firstName,
11 | adaptee.lastName,
12 | adaptee.name,
13 | adaptee.email,
14 | adaptee.bio)
15 | }
16 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/CardAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.CardType
4 | import com.shopify.buy3.Storefront
5 |
6 | object CardAdapter {
7 |
8 | fun adapt(adaptee: List): List {
9 | return adaptee.map { adapt(it) }.mapNotNull { it }
10 | }
11 |
12 | fun adapt(adaptee: Storefront.CardBrand): CardType? {
13 | return when (adaptee) {
14 | Storefront.CardBrand.MASTERCARD -> CardType.MASTER_CARD
15 | Storefront.CardBrand.VISA -> CardType.VISA
16 | Storefront.CardBrand.AMERICAN_EXPRESS -> CardType.AMERICAN_EXPRESS
17 | Storefront.CardBrand.DINERS_CLUB -> CardType.DINERS_CLUB
18 | Storefront.CardBrand.DISCOVER -> CardType.DISCOVER
19 | Storefront.CardBrand.JCB -> CardType.JCB
20 | else -> null
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/CategoryAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Category
4 | import com.shopapp.shopify.constant.Constant.DEFAULT_STRING
5 | import com.shopify.buy3.Storefront
6 |
7 | object CategoryAdapter {
8 |
9 | fun adapt(shop: Storefront.Shop, collection: Storefront.Collection): Category {
10 | return Category(
11 | collection.id.toString(),
12 | collection.title,
13 | collection.description,
14 | collection.descriptionHtml ?: DEFAULT_STRING,
15 | ImageAdapter.adapt(collection.image),
16 | collection.updatedAt.toDate(),
17 | ProductListAdapter.adapt(shop, collection.products)
18 | )
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/CategoryListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Category
4 | import com.shopify.buy3.Storefront
5 |
6 | object CategoryListAdapter {
7 |
8 | fun adapt(shop: Storefront.Shop): List {
9 | return shop.collections.edges.map {
10 | val category = CategoryAdapter.adapt(shop, it.node)
11 | category.paginationValue = it.cursor
12 | category
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/CheckoutAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Checkout
4 | import com.shopify.buy3.Storefront
5 |
6 | object CheckoutAdapter {
7 |
8 | fun adapt(adaptee: Storefront.Checkout): Checkout {
9 | return Checkout(
10 | adaptee.id.toString(),
11 | adaptee.webUrl,
12 | adaptee.requiresShipping,
13 | adaptee.subtotalPrice,
14 | adaptee.totalPrice,
15 | adaptee.totalTax,
16 | adaptee.currencyCode.name,
17 | adaptee.shippingAddress?.let { AddressAdapter.adapt(it) },
18 | adaptee.shippingLine?.let { ShippingRateAdapter.adapt(it) }
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/CountryAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Country
4 | import com.shopapp.shopify.api.entity.ApiCountry
5 |
6 | object CountryAdapter {
7 |
8 | fun adapt(data: ApiCountry): Country {
9 | return Country(
10 | id = data.id,
11 | code = data.code,
12 | name = data.name,
13 | states = StateListAdapter.adapt(data.states)
14 | )
15 | }
16 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/CountryListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Country
4 | import com.shopapp.shopify.api.entity.ApiCountry
5 |
6 | object CountryListAdapter {
7 |
8 | fun adapt(countries: List?): List =
9 | countries?.map { CountryAdapter.adapt(it) } ?: listOf()
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/CustomerAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Customer
4 | import com.shopapp.shopify.constant.Constant.DEFAULT_STRING
5 | import com.shopify.buy3.Storefront
6 |
7 | object CustomerAdapter {
8 |
9 | fun adapt(adaptee: Storefront.Customer): Customer {
10 | return Customer(
11 | adaptee.id.toString(),
12 | adaptee.email,
13 | adaptee.firstName ?: DEFAULT_STRING,
14 | adaptee.lastName ?: DEFAULT_STRING,
15 | adaptee.phone ?: DEFAULT_STRING,
16 | adaptee.acceptsMarketing,
17 | AddressAdapter.adapt(adaptee.addresses),
18 | adaptee.defaultAddress?.let { AddressAdapter.adapt(it) }
19 | )
20 | }
21 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ErrorAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Error
4 | import com.shopify.buy3.GraphError
5 | import com.shopify.buy3.GraphNetworkError
6 | import com.shopify.buy3.Storefront
7 |
8 | object ErrorAdapter {
9 |
10 | fun adapt(adaptee: GraphError): Error = when (adaptee) {
11 | is GraphNetworkError -> Error.Content(isNetworkError = true)
12 | else -> Error.Content()
13 | }
14 |
15 | fun adaptErrors(adaptee: List?): Error? {
16 | return if (adaptee != null) {
17 | adaptee.firstOrNull()?.let { Error.NonCritical(it.message()) }
18 | } else {
19 | null
20 | }
21 | }
22 |
23 | fun adaptUserError(adaptee: List?): Error? {
24 | return if (adaptee != null) {
25 | adaptee.firstOrNull()?.let { Error.NonCritical(it.message) }
26 | } else {
27 | null
28 | }
29 | }
30 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ImageAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Image
4 | import com.shopify.buy3.Storefront
5 |
6 | object ImageAdapter {
7 |
8 | fun adapt(image: Storefront.Image?): Image? {
9 | return if (image != null) {
10 | Image(
11 | image.id.toString(),
12 | image.src,
13 | image.altText
14 | )
15 | } else null
16 | }
17 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/OrderAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Order
4 | import com.shopapp.shopify.api.ext.isSingleOptions
5 | import com.shopify.buy3.Storefront
6 |
7 | object OrderAdapter {
8 |
9 | fun adapt(orderAdaptee: Storefront.Order, paginationValue: String? = null, isRemoveSingleOptions: Boolean = false): Order {
10 |
11 | if (isRemoveSingleOptions) {
12 | orderAdaptee.lineItems.edges.forEach {
13 | val variant = it.node.variant
14 | if (variant != null && variant.product.isSingleOptions()) {
15 | variant.selectedOptions = null
16 | }
17 | }
18 | }
19 |
20 | return Order(
21 | id = orderAdaptee.id.toString(),
22 | currency = orderAdaptee.currencyCode.toString(),
23 | email = orderAdaptee.email,
24 | orderNumber = orderAdaptee.orderNumber,
25 | totalPrice = orderAdaptee.totalPrice,
26 | subtotalPrice = orderAdaptee.subtotalPrice,
27 | totalShippingPrice = orderAdaptee.totalShippingPrice,
28 | address = orderAdaptee.shippingAddress?.let {
29 | AddressAdapter.adapt(it)
30 | },
31 | processedAt = orderAdaptee.processedAt.toDate(),
32 | orderProducts = orderAdaptee.lineItems.edges
33 | .map { it.node }
34 | .filter { it != null }
35 | .map { OrderProductAdapter.adapt(it) },
36 | paginationValue = paginationValue
37 | )
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/OrderListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Order
4 | import com.shopify.buy3.Storefront
5 |
6 | object OrderListAdapter {
7 |
8 | fun adapt(orderConnection: Storefront.OrderConnection?): List =
9 | orderConnection?.edges?.map { OrderAdapter.adapt(it.node, it.cursor) } ?: listOf()
10 | }
11 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/OrderProductAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.OrderProduct
4 | import com.shopify.buy3.Storefront
5 |
6 | object OrderProductAdapter {
7 |
8 | fun adapt(orderAdaptee: Storefront.OrderLineItem): OrderProduct {
9 | return OrderProduct(
10 | title = orderAdaptee.title,
11 | productVariant = orderAdaptee.variant?.let { ProductVariantAdapter.adapt(it) },
12 | quantity = orderAdaptee.quantity
13 | )
14 | }
15 |
16 | }
17 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/PolicyAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Policy
4 | import com.shopify.buy3.Storefront
5 |
6 | object PolicyAdapter {
7 |
8 | fun adapt(adaptee: Storefront.ShopPolicy?): Policy? {
9 | return if (adaptee != null) {
10 | Policy(
11 | adaptee.title,
12 | adaptee.body,
13 | adaptee.url)
14 | } else {
15 | null
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ProductListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Product
4 | import com.shopify.buy3.Storefront
5 |
6 | object ProductListAdapter {
7 |
8 | fun adapt(shop: Storefront.Shop, productConnection: Storefront.ProductConnection?): List =
9 | productConnection?.edges?.map { ProductAdapter.adapt(shop, it.node, it.cursor, true) } ?: listOf()
10 | }
11 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ProductOptionListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.ProductOption
4 | import com.shopify.buy3.Storefront
5 |
6 | object ProductOptionListAdapter {
7 |
8 | fun adapt(adaptee: List?): List =
9 | adaptee?.map { ProductOption(it.id.toString(), it.name, it.values) } ?: listOf()
10 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ProductVariantAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Image
4 | import com.shopapp.gateway.entity.ProductVariant
5 | import com.shopify.buy3.Storefront
6 |
7 | object ProductVariantAdapter {
8 |
9 | fun adapt(adaptee: Storefront.ProductVariant): ProductVariant {
10 | return ProductVariant(
11 | adaptee.id.toString(),
12 | adaptee.title,
13 | adaptee.price,
14 | adaptee.compareAtPrice,
15 | adaptee.availableForSale == true,
16 | VariantOptionListAdapter.adapt(adaptee.selectedOptions),
17 | ImageAdapter.adapt(adaptee.image),
18 | convertImage(adaptee.product)?.firstOrNull(),
19 | adaptee.product.id.toString()
20 | )
21 | }
22 |
23 | private fun convertImage(productAdaptee: Storefront.Product): List? =
24 | productAdaptee.images?.edges?.filterNotNull()?.mapNotNull { ImageAdapter.adapt(it.node) }
25 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ShippingRateAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.ShippingRate
4 | import com.shopify.buy3.Storefront
5 |
6 | object ShippingRateAdapter {
7 |
8 | fun adapt(adaptee: Storefront.ShippingRate): ShippingRate {
9 | return ShippingRate(
10 | adaptee.title,
11 | adaptee.price,
12 | adaptee.handle
13 | )
14 | }
15 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/ShopAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.Shop
4 | import com.shopify.buy3.Storefront
5 |
6 | object ShopAdapter {
7 |
8 | fun adapt(data: Storefront.QueryRoot): Shop {
9 | return Shop(
10 | data.shop.name,
11 | data.shop.description,
12 | PolicyAdapter.adapt(data.shop.privacyPolicy),
13 | PolicyAdapter.adapt(data.shop.refundPolicy),
14 | PolicyAdapter.adapt(data.shop.termsOfService)
15 | )
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/StateAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.State
4 | import com.shopapp.shopify.api.entity.ApiState
5 |
6 | object StateAdapter {
7 |
8 | fun adapt(data: ApiState): State {
9 | return State(
10 | id = data.id,
11 | countryId = data.countryId,
12 | name = data.name,
13 | code = data.code
14 | )
15 | }
16 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/StateListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.State
4 | import com.shopapp.shopify.api.entity.ApiState
5 |
6 | object StateListAdapter {
7 |
8 | fun adapt(states: List?): List =
9 | states?.map { StateAdapter.adapt(it) } ?: listOf()
10 | }
11 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/adapter/VariantOptionListAdapter.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.VariantOption
4 | import com.shopify.buy3.Storefront
5 |
6 | object VariantOptionListAdapter {
7 |
8 | fun adapt(adaptee: List?): List =
9 | adaptee?.map { VariantOption(it.name, it.value) } ?: listOf()
10 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/call/AdapterResult.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.call
2 |
3 | import com.shopapp.gateway.entity.Error
4 |
5 | sealed class AdapterResult {
6 |
7 | class ErrorResult(val error: Error) : AdapterResult()
8 | class DataResult(val data: T) : AdapterResult()
9 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/call/MutationCallWrapper.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.call
2 |
3 | import com.shopapp.gateway.ApiCallback
4 | import com.shopapp.gateway.entity.Error
5 | import com.shopapp.shopify.api.adapter.ErrorAdapter
6 | import com.shopify.buy3.GraphCall
7 | import com.shopify.buy3.GraphError
8 | import com.shopify.buy3.GraphResponse
9 | import com.shopify.buy3.Storefront
10 |
11 | abstract class MutationCallWrapper(private val callback: ApiCallback) : GraphCall.Callback {
12 |
13 | internal abstract fun adapt(data: Storefront.Mutation?): AdapterResult?
14 |
15 | override fun onResponse(response: GraphResponse) {
16 | val error = ErrorAdapter.adaptErrors(response.errors())
17 | val result = adapt(response.data())
18 | when {
19 | error != null -> callback.onFailure(error)
20 | result is AdapterResult.ErrorResult -> callback.onFailure(result.error)
21 | result is AdapterResult.DataResult -> callback.onResult(result.data)
22 | else -> callback.onFailure(Error.Content())
23 | }
24 | }
25 |
26 | override fun onFailure(graphError: GraphError) {
27 | callback.onFailure(ErrorAdapter.adapt(graphError))
28 | }
29 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/call/QueryCallWrapper.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.call
2 |
3 | import com.shopapp.gateway.ApiCallback
4 | import com.shopapp.gateway.entity.Error
5 | import com.shopapp.shopify.api.adapter.ErrorAdapter
6 | import com.shopify.buy3.GraphCall
7 | import com.shopify.buy3.GraphError
8 | import com.shopify.buy3.GraphResponse
9 | import com.shopify.buy3.Storefront
10 |
11 | abstract class QueryCallWrapper(private val callback: ApiCallback) : GraphCall.Callback {
12 |
13 | internal abstract fun adapt(data: Storefront.QueryRoot): AdapterResult
14 |
15 | override fun onResponse(response: GraphResponse) {
16 | val error = ErrorAdapter.adaptErrors(response.errors())
17 | val data = response.data()
18 | val result = data?.let { adapt(it) }
19 | when {
20 | error != null -> callback.onFailure(error)
21 | result is AdapterResult.ErrorResult -> callback.onFailure(result.error)
22 | result is AdapterResult.DataResult -> callback.onResult(result.data)
23 | else -> callback.onFailure(Error.Content())
24 | }
25 | }
26 |
27 | override fun onFailure(graphError: GraphError) {
28 | callback.onFailure(ErrorAdapter.adapt(graphError))
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/entity/AccessData.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.entity
2 |
3 | data class AccessData(
4 | val email: String,
5 | val accessToken: String,
6 | val expiresAt: Long
7 | )
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/entity/ApiCountry.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.entity
2 |
3 | import com.google.gson.annotations.SerializedName
4 |
5 | data class ApiCountry(
6 | val id: Long,
7 | val code: String,
8 | val name: String,
9 | @SerializedName("provinces")
10 | val states: List
11 | )
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/entity/ApiCountryResponse.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.entity
2 |
3 | data class ApiCountryResponse(
4 | val countries: List
5 | )
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/entity/ApiState.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.entity
2 |
3 | import com.google.gson.annotations.SerializedName
4 |
5 | data class ApiState(
6 | val id: Long,
7 | @SerializedName("country_id")
8 | val countryId: Long,
9 | val code: String,
10 | val name: String
11 | )
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/ext/ProductExtension.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.ext
2 |
3 | import com.shopify.buy3.Storefront
4 |
5 | fun Storefront.Product.isSingleOptions(): Boolean {
6 | return options.size == 1 && options.first().values.size == 1
7 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/api/retrofit/CountriesService.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.retrofit
2 |
3 | import com.shopapp.shopify.api.entity.ApiCountryResponse
4 | import retrofit2.Call
5 | import retrofit2.http.GET
6 |
7 | interface CountriesService {
8 |
9 | @GET("/admin/countries.json")
10 | fun getCountries(): Call
11 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/constant/Constant.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.constant
2 |
3 | object Constant {
4 | const val DEFAULT_STRING = ""
5 | const val DEFAULT_SCHEME = "https://"
6 | const val ITEMS_COUNT = 50
7 | const val EMAIL = "email"
8 | const val ACCESS_TOKEN = "access_token"
9 | const val EXPIRES_DATE = "expires_date"
10 | const val RETRY_HANDLER_DELAY = 500L
11 | const val RETRY_HANDLER_MAX_COUNT = 10
12 | const val PRODUCT_TYPE_FILTER_KEY = "product_type:"
13 | const val TITLE_FILTER_KEY = "title:"
14 | const val AND_LOGICAL_KEY = "AND"
15 | const val REST_OF_WORLD = "Rest of World"
16 | const val COUNTRIES_FILE_NAME = "countries.json"
17 | const val UNAUTHORIZED_ERROR = "Unauthorized"
18 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/main/java/com/shopapp/shopify/util/AssetsReader.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.util
2 |
3 | import android.content.Context
4 |
5 | class AssetsReader {
6 |
7 | fun read(filename: String, context: Context): String {
8 | val input = context.assets.open(filename)
9 | val byteArray = ByteArray(input.available())
10 | input.read(byteArray)
11 | input.close()
12 | return String(byteArray)
13 | }
14 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/JodaTimeAndroidRule.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify
2 |
3 | import org.joda.time.DateTimeZone
4 | import org.joda.time.tz.Provider
5 | import org.joda.time.tz.UTCProvider
6 | import org.junit.rules.TestRule
7 | import org.junit.runner.Description
8 | import org.junit.runners.model.Statement
9 |
10 | class JodaTimeAndroidRule : TestRule {
11 |
12 | private val provider: Provider = UTCProvider()
13 |
14 | override fun apply(base: Statement, description: Description) = object : Statement() {
15 | override fun evaluate() {
16 | DateTimeZone.setProvider(provider)
17 | base.evaluate()
18 | }
19 | }
20 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/ArticleAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Assert.assertNotNull
7 | import org.junit.Rule
8 | import org.junit.Test
9 | import org.junit.runner.RunWith
10 | import org.mockito.junit.MockitoJUnitRunner
11 |
12 | @RunWith(MockitoJUnitRunner::class)
13 | class ArticleAdapterTest {
14 |
15 | @Rule
16 | @JvmField
17 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
18 |
19 | @Test
20 | fun shouldAdaptFromArticleStorefrontToArticle() {
21 | val paginationValue = "pagination_value"
22 | val result = ArticleAdapter.adapt(StorefrontMockInstantiator.newArticle(), paginationValue)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_ID, result.id)
24 | assertEquals(StorefrontMockInstantiator.DEFAULT_TITLE, result.title)
25 | assertEquals(StorefrontMockInstantiator.DEFAULT_TITLE, result.blogTitle)
26 | assertEquals(StorefrontMockInstantiator.DEFAULT_ID, result.blogId)
27 | assertEquals(StorefrontMockInstantiator.DEFAULT_DESCRIPTION, result.content)
28 | assertEquals(StorefrontMockInstantiator.DEFAULT_HTML, result.contentHTML)
29 | assertEquals(StorefrontMockInstantiator.DEFAULT_DATE.toDate(), result.publishedAt)
30 | assertNotNull(result.author)
31 | assertNotNull(result.image)
32 | assertNotNull(result.tags)
33 | assertEquals(paginationValue, result.paginationValue)
34 | }
35 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/ArticleListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Rule
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner::class)
12 | class ArticleListAdapterTest {
13 |
14 | @Rule
15 | @JvmField
16 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
17 |
18 | @Test
19 | fun shouldAdaptFromArticleStorefrontListToArticleList() {
20 | val result = ArticleListAdapter.adapt(listOf(StorefrontMockInstantiator.newArticleEdge()))
21 | assertEquals(1, result.size)
22 | }
23 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/AuthorAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Rule
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner::class)
12 | class AuthorAdapterTest {
13 |
14 | @Rule
15 | @JvmField
16 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
17 |
18 | @Test
19 | fun shouldAdaptFromAuthorStorefrontToAuthor() {
20 | val result = AuthorAdapter.adapt(StorefrontMockInstantiator.newAuthor())
21 | assertEquals(StorefrontMockInstantiator.DEFAULT_FIRST_NAME, result.firstName)
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_LAST_NAME, result.lastName)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_NAME, result.fullName)
24 | assertEquals(StorefrontMockInstantiator.DEFAULT_BIO, result.bio)
25 | assertEquals(StorefrontMockInstantiator.DEFAULT_EMAIL, result.email)
26 | }
27 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/CardAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.gateway.entity.CardType
4 | import com.shopapp.shopify.JodaTimeAndroidRule
5 | import com.shopify.buy3.Storefront
6 | import org.junit.Assert.assertEquals
7 | import org.junit.Assert.assertNull
8 | import org.junit.Rule
9 | import org.junit.Test
10 | import org.junit.runner.RunWith
11 | import org.mockito.junit.MockitoJUnitRunner
12 |
13 | @RunWith(MockitoJUnitRunner::class)
14 | class CardAdapterTest {
15 |
16 | @Rule
17 | @JvmField
18 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
19 |
20 | @Test
21 | fun shouldAdaptFromStorefrontCardBrandToCardType() {
22 | assertEquals(CardType.AMERICAN_EXPRESS, CardAdapter.adapt(Storefront.CardBrand.AMERICAN_EXPRESS))
23 | assertEquals(CardType.DINERS_CLUB, CardAdapter.adapt(Storefront.CardBrand.DINERS_CLUB))
24 | assertEquals(CardType.DISCOVER, CardAdapter.adapt(Storefront.CardBrand.DISCOVER))
25 | assertEquals(CardType.JCB, CardAdapter.adapt(Storefront.CardBrand.JCB))
26 | assertEquals(CardType.MASTER_CARD, CardAdapter.adapt(Storefront.CardBrand.MASTERCARD))
27 | assertEquals(CardType.VISA, CardAdapter.adapt(Storefront.CardBrand.VISA))
28 | assertNull(CardAdapter.adapt(Storefront.CardBrand.UNKNOWN_VALUE))
29 | }
30 |
31 | @Test
32 | fun shouldAdaptFromListStorefrontCardBrandsToListCardType() {
33 | val srcList = listOf(Storefront.CardBrand.VISA, Storefront.CardBrand.MASTERCARD, Storefront.CardBrand.UNKNOWN_VALUE)
34 | val result = CardAdapter.adapt(srcList)
35 | assertEquals(2, result.size)
36 | assertEquals(CardType.VISA, result[0])
37 | assertEquals(CardType.MASTER_CARD, result[1])
38 | }
39 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/CategoryListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Rule
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner.Silent::class)
12 | class CategoryListAdapterTest {
13 |
14 | @Rule
15 | @JvmField
16 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
17 |
18 | @Test
19 | fun shouldAdaptFromListCollectionStorefrontToListCategory() {
20 | val shop = StorefrontMockInstantiator.newShop()
21 | val categoryList = CategoryListAdapter.adapt(shop)
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_LIST_SIZE, categoryList.size)
23 | }
24 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/CountryAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Assert.assertNotNull
7 | import org.junit.Rule
8 | import org.junit.Test
9 | import org.junit.runner.RunWith
10 | import org.mockito.junit.MockitoJUnitRunner
11 |
12 | @RunWith(MockitoJUnitRunner::class)
13 | class CountryAdapterTest {
14 |
15 | @Rule
16 | @JvmField
17 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
18 |
19 | @Test
20 | fun shouldAdaptFromApiCountryToCountry() {
21 | val country = CountryAdapter.adapt(StorefrontMockInstantiator.newCountry())
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_NUMBER_ID, country.id)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_COUNTRY, country.name)
24 | assertEquals(StorefrontMockInstantiator.DEFAULT_COUNTRY_CODE, country.code)
25 | assertEquals(StorefrontMockInstantiator.DEFAULT_LIST_SIZE, country.states?.size)
26 | assertNotNull(country.states)
27 | }
28 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/CountryListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import com.shopapp.shopify.api.entity.ApiCountry
6 | import org.junit.Assert.*
7 | import org.junit.Rule
8 | import org.junit.Test
9 | import org.junit.runner.RunWith
10 | import org.mockito.junit.MockitoJUnitRunner
11 |
12 | @RunWith(MockitoJUnitRunner::class)
13 | class CountryListAdapterTest {
14 |
15 | @Rule
16 | @JvmField
17 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
18 |
19 | @Test
20 | fun shouldAdaptFromApiCountryListToCountryList() {
21 | val list = StorefrontMockInstantiator.newList(StorefrontMockInstantiator.newCountry())
22 | val countries = CountryListAdapter.adapt(list)
23 | assertNotNull(countries)
24 | assertEquals(StorefrontMockInstantiator.DEFAULT_LIST_SIZE, countries.size)
25 | }
26 |
27 | @Test
28 | fun shouldReturnEmptyList() {
29 | val list: List? = null
30 | val countries = CountryListAdapter.adapt(list)
31 | assertNotNull(countries)
32 | assertTrue(countries.isEmpty())
33 | }
34 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/ImageAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.*
6 | import org.junit.Rule
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner::class)
12 | class ImageAdapterTest {
13 |
14 | @Rule
15 | @JvmField
16 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
17 |
18 | @Test
19 | fun shouldAdaptFromImageStorefrontToImage() {
20 | val result = ImageAdapter.adapt(StorefrontMockInstantiator.newImage())
21 | assertNotNull(result!!)
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_ID, result.id)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_SRC, result.src)
24 | assertEquals(StorefrontMockInstantiator.DEFAULT_ALT_TEXT, result.alt)
25 | }
26 |
27 | @Test
28 | fun shouldReturnNull() {
29 | val result = ImageAdapter.adapt(null)
30 | assertNull(result)
31 | }
32 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/OrderListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.nhaarman.mockito_kotlin.doReturn
4 | import com.nhaarman.mockito_kotlin.mock
5 | import com.shopapp.shopify.JodaTimeAndroidRule
6 | import com.shopapp.shopify.StorefrontMockInstantiator
7 | import com.shopify.buy3.Storefront
8 | import org.junit.Assert.*
9 | import org.junit.Rule
10 | import org.junit.Test
11 | import org.junit.runner.RunWith
12 | import org.mockito.junit.MockitoJUnitRunner
13 |
14 | @RunWith(MockitoJUnitRunner::class)
15 | class OrderListAdapterTest {
16 |
17 | @Rule
18 | @JvmField
19 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
20 |
21 | @Test
22 | fun shouldAdaptFromOrderListStorefrontToOrderList() {
23 | val result = OrderListAdapter.adapt(StorefrontMockInstantiator.newOrderConnection())
24 | assertEquals(1, result.size)
25 | assertNotNull(result.first())
26 | }
27 |
28 | @Test
29 | fun shouldReturnEmptyListOnNullConnection() {
30 | val result = OrderListAdapter.adapt(null)
31 | assertNotNull(result)
32 | assertTrue(result.isEmpty())
33 | }
34 |
35 | @Test
36 | fun shouldReturnEmptyListOnNullEdges() {
37 | val edgesMock: List? = null
38 | val connection: Storefront.OrderConnection = mock {
39 | on { edges } doReturn edgesMock
40 | }
41 | val result = OrderListAdapter.adapt(connection)
42 | assertNotNull(result)
43 | assertTrue(result.isEmpty())
44 | }
45 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/OrderProductAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.nhaarman.mockito_kotlin.given
4 | import com.shopapp.shopify.JodaTimeAndroidRule
5 | import com.shopapp.shopify.StorefrontMockInstantiator
6 | import org.junit.Assert.*
7 | import org.junit.Rule
8 | import org.junit.Test
9 | import org.junit.runner.RunWith
10 | import org.mockito.junit.MockitoJUnitRunner
11 |
12 | @RunWith(MockitoJUnitRunner::class)
13 | class OrderProductAdapterTest {
14 |
15 | @Rule
16 | @JvmField
17 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
18 |
19 | @Test
20 | fun shouldAdaptFromOrderLineItemStorefrontToOrderProduct() {
21 | val result = OrderProductAdapter.adapt(StorefrontMockInstantiator.newOrderLineItem())
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_QUANTITY, result.quantity)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_TITLE, result.title)
24 | assertNotNull(result.productVariant)
25 | }
26 |
27 | @Test
28 | fun shouldAdaptFromOrderLineItemStorefrontToOrderProductWhenProductVariantIsNull() {
29 | val adaptee = StorefrontMockInstantiator.newOrderLineItem()
30 | given(adaptee.variant).willReturn(null)
31 | val result = OrderProductAdapter.adapt(adaptee)
32 | assertEquals(StorefrontMockInstantiator.DEFAULT_QUANTITY, result.quantity)
33 | assertEquals(StorefrontMockInstantiator.DEFAULT_TITLE, result.title)
34 | assertNull(result.productVariant)
35 | }
36 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/PolicyAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Assert.assertNull
7 | import org.junit.Rule
8 | import org.junit.Test
9 | import org.junit.runner.RunWith
10 | import org.mockito.junit.MockitoJUnitRunner
11 |
12 | @RunWith(MockitoJUnitRunner::class)
13 | class PolicyAdapterTest {
14 |
15 | @Rule
16 | @JvmField
17 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
18 |
19 | @Test
20 | fun shouldAdaptFromPolicyStorefrontToPolicy() {
21 | val policy = PolicyAdapter.adapt(StorefrontMockInstantiator.newPolicy())!!
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_TITLE, policy.title)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_BODY, policy.body)
24 | assertEquals(StorefrontMockInstantiator.DEFAULT_URL, policy.url)
25 | }
26 |
27 | @Test
28 | fun shouldReturnNullPolicy() {
29 | val result = PolicyAdapter.adapt(null)
30 | assertNull(result)
31 | }
32 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/ProductListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.nhaarman.mockito_kotlin.doReturn
4 | import com.nhaarman.mockito_kotlin.mock
5 | import com.shopapp.shopify.JodaTimeAndroidRule
6 | import com.shopapp.shopify.StorefrontMockInstantiator
7 | import com.shopify.buy3.Storefront
8 | import org.junit.Assert.*
9 | import org.junit.Rule
10 | import org.junit.Test
11 | import org.junit.runner.RunWith
12 | import org.mockito.junit.MockitoJUnitRunner
13 |
14 | @RunWith(MockitoJUnitRunner.Silent::class)
15 | class ProductListAdapterTest {
16 |
17 | @Rule
18 | @JvmField
19 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
20 |
21 | @Test
22 | fun shouldAdaptFromApiCountryListToCountryList() {
23 | val products = ProductListAdapter.adapt(StorefrontMockInstantiator.newShop(), StorefrontMockInstantiator.newProductConnection())
24 | assertNotNull(products)
25 | assertEquals(StorefrontMockInstantiator.DEFAULT_LIST_SIZE, products.size)
26 | }
27 |
28 | @Test
29 | fun shouldReturnEmptyListOnNullConnection() {
30 | val products = ProductListAdapter.adapt(StorefrontMockInstantiator.newShop(), null)
31 | assertNotNull(products)
32 | assertTrue(products.isEmpty())
33 | }
34 |
35 | @Test
36 | fun shouldReturnEmptyListOnNullEdges() {
37 | val edgesMock: List? = null
38 | val connection: Storefront.ProductConnection = mock {
39 | on { edges } doReturn edgesMock
40 | }
41 | val products = ProductListAdapter.adapt(StorefrontMockInstantiator.newShop(), connection)
42 | assertNotNull(products)
43 | assertTrue(products.isEmpty())
44 | }
45 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/ProductOptionListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.*
6 | import org.junit.Rule
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner::class)
12 | class ProductOptionListAdapterTest {
13 |
14 | @Rule
15 | @JvmField
16 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
17 |
18 | @Test
19 | fun shouldAdaptFromApiCountryListToCountryList() {
20 | val list = StorefrontMockInstantiator.newList(StorefrontMockInstantiator.newProductOption())
21 | val options = ProductOptionListAdapter.adapt(list)
22 | assertNotNull(options)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_LIST_SIZE, options.size)
24 |
25 | val option = options[0]
26 | assertEquals(StorefrontMockInstantiator.DEFAULT_ID, option.id)
27 | assertEquals(StorefrontMockInstantiator.DEFAULT_NAME, option.name)
28 | assertNotNull(option.values)
29 | assertEquals(3, option.values.size)
30 | }
31 |
32 | @Test
33 | fun shouldReturnEmptyListOnNullConnection() {
34 | val options = ProductOptionListAdapter.adapt(null)
35 | assertNotNull(options)
36 | assertTrue(options.isEmpty())
37 | }
38 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/ShippingRateAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Rule
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner::class)
12 | class ShippingRateAdapterTest {
13 |
14 | @Rule
15 | @JvmField
16 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
17 |
18 | @Test
19 | fun shouldAdaptFromShippingRateStorefrontToShippingRate() {
20 | val rate = ShippingRateAdapter.adapt(StorefrontMockInstantiator.newShippingRate())
21 | assertEquals(StorefrontMockInstantiator.DEFAULT_TITLE, rate.title)
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_HANDLE, rate.handle)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_PRICE, rate.price)
24 | }
25 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/ShopAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Assert.assertNotNull
7 | import org.junit.Rule
8 | import org.junit.Test
9 | import org.junit.runner.RunWith
10 | import org.mockito.junit.MockitoJUnitRunner
11 |
12 | @RunWith(MockitoJUnitRunner.Silent::class)
13 | class ShopAdapterTest {
14 |
15 | @Rule
16 | @JvmField
17 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
18 |
19 | @Test
20 | fun shouldAdaptFromQueryRootStorefrontToShop() {
21 | val shop = ShopAdapter.adapt(StorefrontMockInstantiator.newQueryRoot())
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_SHOP_NAME, shop.name)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_DESCRIPTION, shop.description)
24 | assertNotNull(shop.privacyPolicy)
25 | assertNotNull(shop.refundPolicy)
26 | assertNotNull(shop.termsOfService)
27 | }
28 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/StateAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import org.junit.Assert.assertEquals
6 | import org.junit.Rule
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner::class)
12 | class StateAdapterTest {
13 |
14 | @Rule
15 | @JvmField
16 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
17 |
18 | @Test
19 | fun shouldAdaptFromApiStateToState() {
20 | val state = StateAdapter.adapt(StorefrontMockInstantiator.newState())
21 | assertEquals(StorefrontMockInstantiator.DEFAULT_NUMBER_ID, state.id)
22 | assertEquals(StorefrontMockInstantiator.DEFAULT_NUMBER_ID, state.countryId)
23 | assertEquals(StorefrontMockInstantiator.DEFAULT_STATE_CODE, state.code)
24 | assertEquals(StorefrontMockInstantiator.DEFAULT_STATE, state.name)
25 | }
26 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/StateListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.JodaTimeAndroidRule
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import com.shopapp.shopify.api.entity.ApiCountry
6 | import com.shopapp.shopify.api.entity.ApiState
7 | import org.junit.Assert
8 | import org.junit.Assert.assertEquals
9 | import org.junit.Assert.assertNotNull
10 | import org.junit.Rule
11 | import org.junit.Test
12 | import org.junit.runner.RunWith
13 | import org.mockito.junit.MockitoJUnitRunner
14 |
15 | @RunWith(MockitoJUnitRunner::class)
16 | class StateListAdapterTest {
17 |
18 | @Rule
19 | @JvmField
20 | var jodaTimeAndroidRule = JodaTimeAndroidRule()
21 |
22 | @Test
23 | fun shouldAdaptFromApiStateListToStateList() {
24 | val list = StorefrontMockInstantiator.newList(StorefrontMockInstantiator.newState())
25 | val states = StateListAdapter.adapt(list)
26 | assertNotNull(states)
27 | assertEquals(StorefrontMockInstantiator.DEFAULT_LIST_SIZE, states.size)
28 | }
29 |
30 | @Test
31 | fun shouldReturnEmptyList() {
32 | val list: List? = null
33 | val states = StateListAdapter.adapt(list)
34 | assertNotNull(states)
35 | Assert.assertTrue(states.isEmpty())
36 | }
37 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/api/adapter/VariantOptionListAdapterTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.api.adapter
2 |
3 | import com.shopapp.shopify.StorefrontMockInstantiator
4 | import com.shopapp.shopify.api.entity.ApiState
5 | import org.junit.Assert
6 | import org.junit.Assert.*
7 | import org.junit.Test
8 | import org.junit.runner.RunWith
9 | import org.mockito.junit.MockitoJUnitRunner
10 |
11 | @RunWith(MockitoJUnitRunner::class)
12 | class VariantOptionListAdapterTest {
13 |
14 | @Test
15 | fun shouldAdaptFromOptionListStorefrontToVariantOptionList() {
16 | val resultList = VariantOptionListAdapter.adapt(listOf(StorefrontMockInstantiator.newSelectedOption()))
17 | val result = resultList.first()
18 | assertEquals(StorefrontMockInstantiator.DEFAULT_NAME, result.name)
19 | assertEquals(StorefrontMockInstantiator.DEFAULT_VALUE, result.value)
20 | }
21 |
22 | @Test
23 | fun shouldReturnEmptyList() {
24 | val resultList = VariantOptionListAdapter.adapt(null)
25 | assertNotNull(resultList)
26 | assertTrue(resultList.isEmpty())
27 | }
28 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/java/com/shopapp/shopify/ext/ProductExtensionTest.kt:
--------------------------------------------------------------------------------
1 | package com.shopapp.shopify.ext
2 |
3 | import com.nhaarman.mockito_kotlin.given
4 | import com.shopapp.shopify.StorefrontMockInstantiator
5 | import com.shopapp.shopify.api.ext.isSingleOptions
6 | import com.shopify.buy3.Storefront
7 | import org.junit.Assert.assertFalse
8 | import org.junit.Assert.assertTrue
9 | import org.junit.Test
10 | import org.junit.runner.RunWith
11 | import org.mockito.junit.MockitoJUnitRunner
12 |
13 | @RunWith(MockitoJUnitRunner.Silent::class)
14 | class ProductExtensionTest {
15 |
16 | @Test
17 | fun shouldReturnFalse() {
18 | val storefrontProduct = StorefrontMockInstantiator.newProduct()
19 | assertFalse(storefrontProduct.isSingleOptions())
20 | }
21 |
22 | @Test
23 | fun shouldReturnTrueIfOnlySingleOptionExists() {
24 | val defaultValue = listOf(StorefrontMockInstantiator.DEFAULT_TITLE)
25 | val option: Storefront.ProductOption = StorefrontMockInstantiator.newProductOption()
26 | given(option.values).willReturn(defaultValue)
27 |
28 | val storefrontProduct = StorefrontMockInstantiator.newProduct()
29 | given(storefrontProduct.options).willReturn(listOf(option))
30 | assertTrue(storefrontProduct.isSingleOptions())
31 | }
32 | }
--------------------------------------------------------------------------------
/android/library/shopifylibrary/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker:
--------------------------------------------------------------------------------
1 | mock-maker-inline
--------------------------------------------------------------------------------
/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'shopify'
2 |
--------------------------------------------------------------------------------
/android/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/plugin/arch/PluginContext.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.plugin.arch;
2 |
3 | import android.os.Handler;
4 |
5 | import com.jvanila.flutter.shopify.Api;
6 |
7 |
8 | /**
9 | * Created by pavan on 23/09/18
10 | */
11 | public class PluginContext {
12 |
13 | public Plugin plugin;
14 | public Api api;
15 | public Handler executor;
16 | public boolean debug;
17 |
18 | public static boolean isDirty(PluginContext> context) {
19 | return context == null || context.plugin == null || context.api == null ||
20 | context.executor == null;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/plugin/arch/UseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.plugin.arch;
2 |
3 | import io.flutter.plugin.common.MethodCall;
4 | import io.flutter.plugin.common.MethodChannel;
5 |
6 | /**
7 | * Created by pavan on 22/09/18
8 | */
9 | public abstract class UseCase {
10 |
11 | protected final PluginContext mPluginContext;
12 | protected Runnable mLastExecution;
13 |
14 | public UseCase(PluginContext pluginContext) {
15 | mPluginContext = pluginContext;
16 | }
17 |
18 | public void execute(final I input, final O result) {
19 | if (!canExecute(input)) {
20 | result.error(this.getClass().getSimpleName(), "Either input or arguments are null",
21 | null);
22 | return;
23 | }
24 |
25 | dispose();
26 | mLastExecution = buildRunnableUseCase(input, result);
27 | mPluginContext.executor.post(mLastExecution);
28 | }
29 |
30 | private boolean canExecute(I input) {
31 | return !PluginContext.isDirty(mPluginContext) && input != null;
32 | }
33 |
34 | private Runnable buildRunnableUseCase(final I input, final O result) {
35 | return () -> call(input, result);
36 | }
37 |
38 | protected abstract void call(I input, O result);
39 |
40 | public void dispose() {
41 | if (mLastExecution != null) {
42 | mPluginContext.executor.removeCallbacks(mLastExecution);
43 | mLastExecution = null;
44 | }
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/plugin/arch/UseCaseResult.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.plugin.arch;
2 |
3 | import android.os.Handler;
4 |
5 | import io.flutter.plugin.common.MethodChannel;
6 |
7 | /**
8 | * Created by pavan on 22/09/18
9 | */
10 | public class UseCaseResult implements MethodChannel.Result {
11 |
12 | private final Handler mCallerHandler;
13 | private final MethodChannel.Result mResult;
14 |
15 | UseCaseResult(Handler callerHandler, MethodChannel.Result result) {
16 | this.mCallerHandler = callerHandler;
17 | this.mResult = result;
18 | }
19 |
20 | /*
21 | * Make sure to respond in the caller thread
22 | */
23 | public void success(final Object results) {
24 | mCallerHandler.post(() -> mResult.success(results));
25 | }
26 |
27 | public void error(final String errorCode, final String errorMessage, final Object data) {
28 | mCallerHandler.post(() -> mResult.error(errorCode, errorMessage, "{error : "+data+"}"));
29 | }
30 |
31 | @Override
32 | public void notImplemented() {
33 | mCallerHandler.post(() -> mResult.notImplemented());
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/Api.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify;
2 |
3 | /**
4 | * Created by pavan on 22/09/18
5 | */
6 | public class Api {
7 |
8 | public T instance;
9 | }
10 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/ChangePasswordUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 | import kotlin.Unit;
11 |
12 | public class ChangePasswordUseCase extends ShopifyCallUseCase {
13 |
14 | private static final String ARG_PASSWORD = "password";
15 |
16 | public ChangePasswordUseCase(PluginContext pluginContext) {
17 | super(pluginContext);
18 | }
19 |
20 | @Override
21 | protected void call(MethodCall input, final MethodChannel.Result result) {
22 | String password = input.argument(ARG_PASSWORD);
23 | mPluginContext.api.instance.changePassword(password, new ApiCallback() {
24 | @Override
25 | public void onResult(Unit unit) {
26 | result.success(true);
27 | }
28 |
29 | @Override
30 | public void onFailure(Error error) {
31 | result.error("ChangePasswordUseCase", error.getMessage(), error);
32 | }
33 | });
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/CreateCustomerAddressUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Address;
8 | import com.shopapp.gateway.entity.Error;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import io.flutter.plugin.common.MethodCall;
12 | import io.flutter.plugin.common.MethodChannel;
13 |
14 | public class CreateCustomerAddressUseCase extends ShopifyCallUseCase {
15 |
16 | private static final String ARG_ADDRESS_JSON = "addressJson";
17 |
18 | public CreateCustomerAddressUseCase(PluginContext pluginContext) {
19 | super(pluginContext);
20 | }
21 |
22 | @Override
23 | protected void call(MethodCall input, final MethodChannel.Result result) {
24 |
25 | String addressJson = input.argument(ARG_ADDRESS_JSON);
26 |
27 | Address addr = new Gson().fromJson(addressJson,
28 | new TypeToken() {
29 | }.getType());
30 |
31 | mPluginContext.api.instance.createCustomerAddress(addr, new ApiCallback() {
32 | @Override
33 | public void onResult(String addressId) {
34 | result.success(addressId);
35 | }
36 |
37 | @Override
38 | public void onFailure(Error error) {
39 | System.out.println("onFailure -- " + error);
40 | result.error("CreateCustomerAddressUseCase", error.getMessage(), error);
41 | }
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/DeleteCustomerAddressUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 | import kotlin.Unit;
11 |
12 | public class DeleteCustomerAddressUseCase extends ShopifyCallUseCase {
13 |
14 | private static final String ARG_ADDRESS_ID = "addressId";
15 |
16 | public DeleteCustomerAddressUseCase(PluginContext pluginContext) {
17 | super(pluginContext);
18 | }
19 |
20 | @Override
21 | protected void call(MethodCall input, final MethodChannel.Result result) {
22 | String addressId = input.argument(ARG_ADDRESS_ID);
23 | mPluginContext.api.instance.deleteCustomerAddress(addressId, new ApiCallback() {
24 | @Override
25 | public void onResult(Unit unit) {
26 | result.success(true);
27 | }
28 |
29 | @Override
30 | public void onFailure(Error error) {
31 | System.out.println("onFailure -- " + error);
32 | result.error("DeleteCustomerAddressUseCase", error.getMessage(), error);
33 | }
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/ForgotPasswordUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 | import kotlin.Unit;
11 |
12 | public class ForgotPasswordUseCase extends ShopifyCallUseCase {
13 |
14 | private static final String ARG_EMAIL = "email";
15 |
16 | public ForgotPasswordUseCase(PluginContext pluginContext) {
17 | super(pluginContext);
18 | }
19 |
20 | @Override
21 | protected void call(MethodCall input, final MethodChannel.Result result) {
22 | String email = input.argument(ARG_EMAIL);
23 | mPluginContext.api.instance.forgotPassword(email, new ApiCallback() {
24 | @Override
25 | public void onResult(Unit unit) {
26 | result.success(true);
27 | }
28 |
29 | @Override
30 | public void onFailure(Error error) {
31 | System.out.println("onFailure -- " + error);
32 | result.error("ForgotPasswordUseCase", error.getMessage(), error);
33 | }
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetAcceptedCardTypesUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.CardType;
8 | import com.shopapp.gateway.entity.Error;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import java.util.List;
12 |
13 | import io.flutter.plugin.common.MethodCall;
14 | import io.flutter.plugin.common.MethodChannel;
15 |
16 | public class GetAcceptedCardTypesUseCase extends ShopifyCallUseCase {
17 |
18 | public GetAcceptedCardTypesUseCase(PluginContext pluginContext) {
19 | super(pluginContext);
20 | }
21 |
22 | @Override
23 | protected void call(MethodCall input, final MethodChannel.Result result) {
24 | mPluginContext.api.instance.getAcceptedCardTypes(new ApiCallback>() {
25 | @Override
26 | public void onResult(List extends CardType> cardTypes) {
27 | if (cardTypes != null && cardTypes.size() > 0) {
28 |
29 | String cardTypesJsonString = new Gson().toJson(cardTypes,
30 | new TypeToken>() {
31 | }.getType());
32 |
33 | result.success(cardTypesJsonString);
34 | } else {
35 | System.out.println("No available Card Types.");
36 | }
37 | }
38 |
39 | @Override
40 | public void onFailure(Error error) {
41 | System.out.println("onFailure -- " + error);
42 | }
43 | });
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetAccessTokenUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 |
11 | public class GetAccessTokenUseCase extends ShopifyCallUseCase {
12 |
13 | public GetAccessTokenUseCase(PluginContext pluginContext) {
14 | super(pluginContext);
15 | }
16 |
17 | @Override
18 | protected void call(final MethodCall input, final MethodChannel.Result result) {
19 |
20 | mPluginContext.api.instance.getAccessToken(new ApiCallback() {
21 | @Override
22 | public void onResult(String token) {
23 | System.out.println("AccessToken -- " + token);
24 | result.success(token);
25 | }
26 |
27 | @Override
28 | public void onFailure(Error error) {
29 | System.out.println("onFailure -- " + error);
30 | result.error("GetAccessTokenUseCase", error.getMessage(), error);
31 | }
32 | });
33 |
34 | //result.success("a4a78e07552b76eab90dba533d60e318");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetArticleUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Article;
8 | import com.shopapp.gateway.entity.Error;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import io.flutter.plugin.common.MethodCall;
12 | import io.flutter.plugin.common.MethodChannel;
13 | import kotlin.Pair;
14 |
15 | public class GetArticleUseCase extends ShopifyCallUseCase {
16 |
17 | private static final String ARG_ARTICLE_ID = "articleId";
18 |
19 | public GetArticleUseCase(PluginContext pluginContext) {
20 | super(pluginContext);
21 | }
22 |
23 | @Override
24 | protected void call(MethodCall input, final MethodChannel.Result result) {
25 | String articleId = input.argument(ARG_ARTICLE_ID);
26 |
27 | mPluginContext.api.instance.getArticle(articleId, new ApiCallback>() {
28 | @Override
29 | public void onResult(Pair articleStringPair) {
30 | //TODO test
31 | if (articleStringPair != null) {
32 | String articlesJsonString = new Gson().toJson(articleStringPair,
33 | new TypeToken() {
34 | }.getType());
35 | result.success(articlesJsonString);
36 | } else {
37 | System.out.println("Article list is empty");
38 | }
39 | }
40 |
41 | @Override
42 | public void onFailure(Error error) {
43 |
44 | }
45 | });
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetCheckoutUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Checkout;
8 | import com.shopapp.gateway.entity.Error;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import io.flutter.plugin.common.MethodCall;
12 | import io.flutter.plugin.common.MethodChannel;
13 |
14 | public class GetCheckoutUseCase extends ShopifyCallUseCase {
15 |
16 | private static final String ARG_CHECKOUT_ID = "checkoutId";
17 |
18 | public GetCheckoutUseCase(PluginContext pluginContext) {
19 | super(pluginContext);
20 | }
21 |
22 | @Override
23 | protected void call(MethodCall input, final MethodChannel.Result result) {
24 | String checkoutId = input.argument(ARG_CHECKOUT_ID);
25 | mPluginContext.api.instance.getCheckout(checkoutId, new ApiCallback() {
26 | @Override
27 | public void onResult(Checkout checkout) {
28 | if (checkout != null) {
29 |
30 | String checkoutJsonString = new Gson().toJson(checkout,
31 | new TypeToken() {
32 | }.getType());
33 |
34 | result.success(checkoutJsonString);
35 | }
36 | }
37 |
38 | @Override
39 | public void onFailure(Error error) {
40 | System.out.println("onFailure -- " + error);
41 | result.error("GetCheckoutUseCase", error.getMessage(), error);
42 | }
43 | });
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetCountriesUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Country;
8 | import com.shopapp.gateway.entity.Error;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import java.util.List;
12 |
13 | import io.flutter.plugin.common.MethodCall;
14 | import io.flutter.plugin.common.MethodChannel;
15 |
16 | public class GetCountriesUseCase extends ShopifyCallUseCase {
17 |
18 | public GetCountriesUseCase(PluginContext pluginContext) {
19 | super(pluginContext);
20 | }
21 |
22 | @Override
23 | protected void call(MethodCall input, final MethodChannel.Result result) {
24 | mPluginContext.api.instance.getCountries(new ApiCallback>() {
25 | @Override
26 | public void onResult(List countries) {
27 | if (countries != null && countries.size() > 0) {
28 |
29 | String countriesJsonString = new Gson().toJson(countries,
30 | new TypeToken>() {
31 | }.getType());
32 |
33 | result.success(countriesJsonString);
34 | }
35 | }
36 |
37 | @Override
38 | public void onFailure(Error error) {
39 | System.out.println("onFailure -- " + error);
40 | result.error("GetCountriesUseCase", error.getMessage(), error);
41 | }
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetCustomerUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Customer;
8 | import com.shopapp.gateway.entity.Error;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import io.flutter.plugin.common.MethodCall;
12 | import io.flutter.plugin.common.MethodChannel;
13 |
14 | public class GetCustomerUseCase extends ShopifyCallUseCase {
15 |
16 | public GetCustomerUseCase(PluginContext pluginContext) {
17 | super(pluginContext);
18 | }
19 |
20 | @Override
21 | protected void call(MethodCall input, final MethodChannel.Result result) {
22 | mPluginContext.api.instance.getCustomer(new ApiCallback() {
23 | @Override
24 | public void onResult(Customer customer) {
25 | if (customer != null) {
26 |
27 | String customerJsonString = new Gson().toJson(customer,
28 | new TypeToken() {
29 | }.getType());
30 |
31 | result.success(customerJsonString);
32 | }
33 | }
34 |
35 | @Override
36 | public void onFailure(Error error) {
37 | //Unauthorised
38 | // result.success("onFailure -- " + error);
39 |
40 | result.error("GetCustomerUseCase", error.getMessage(), error);
41 | System.out.println("onFailure -- " + error);
42 | }
43 | });
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetOrderUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Error;
8 | import com.shopapp.gateway.entity.Order;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import io.flutter.plugin.common.MethodCall;
12 | import io.flutter.plugin.common.MethodChannel;
13 |
14 | public class GetOrderUseCase extends ShopifyCallUseCase {
15 |
16 | private static final String ARG_ORDER_ID = "orderId";
17 |
18 | public GetOrderUseCase(PluginContext pluginContext) {
19 | super(pluginContext);
20 | }
21 |
22 | @Override
23 | protected void call(MethodCall input, final MethodChannel.Result result) {
24 | String orderId = input.argument(ARG_ORDER_ID);
25 | mPluginContext.api.instance.getOrder(orderId, new ApiCallback() {
26 | @Override
27 | public void onResult(Order order) {
28 | if (order != null) {
29 |
30 | String orderJsonString = new Gson().toJson(order,
31 | new TypeToken() {
32 | }.getType());
33 |
34 | result.success(orderJsonString);
35 | }
36 | }
37 |
38 | @Override
39 | public void onFailure(Error error) {
40 | System.out.println("onFailure -- " + error);
41 | result.error("GetOrderUseCase", error.getMessage(), error);
42 | }
43 | });
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetProductUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Error;
8 | import com.shopapp.gateway.entity.Product;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import io.flutter.plugin.common.MethodCall;
12 | import io.flutter.plugin.common.MethodChannel;
13 |
14 | /**
15 | * Created by pragna on 24/09/18
16 | */
17 | public class GetProductUseCase extends ShopifyCallUseCase {
18 |
19 | private static final String ARG_PRODUCT_ID = "productId";
20 |
21 | public GetProductUseCase(PluginContext pluginContext) {
22 | super(pluginContext);
23 | }
24 |
25 | @Override
26 | protected void call(MethodCall input, final MethodChannel.Result result) {
27 |
28 | String productId = input.argument(ARG_PRODUCT_ID);
29 |
30 | mPluginContext.api.instance.getProduct(productId, new ApiCallback() {
31 | @Override
32 | public void onResult(Product product) {
33 | if (product != null) {
34 |
35 | String productJsonString = new Gson().toJson(product,
36 | new TypeToken() {
37 | }.getType());
38 |
39 | result.success(productJsonString);
40 | }
41 | }
42 |
43 | @Override
44 | public void onFailure(Error error) {
45 | System.out.println("onFailure -- " + error);
46 | result.error("GetProductUseCase", error.getMessage(), error);
47 | }
48 | });
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetShippingRatesUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Error;
8 | import com.shopapp.gateway.entity.ShippingRate;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import java.util.List;
12 |
13 | import io.flutter.plugin.common.MethodCall;
14 | import io.flutter.plugin.common.MethodChannel;
15 |
16 | public class GetShippingRatesUseCase extends ShopifyCallUseCase {
17 |
18 | private static final String ARG_CHECKOUT_ID = "checkoutId";
19 |
20 | public GetShippingRatesUseCase(PluginContext pluginContext) {
21 | super(pluginContext);
22 | }
23 |
24 | @Override
25 | protected void call(MethodCall input, final MethodChannel.Result result) {
26 | String checkoutId = input.argument(ARG_CHECKOUT_ID);
27 | mPluginContext.api.instance.getShippingRates(checkoutId, new ApiCallback>() {
28 | @Override
29 | public void onResult(List shippingRates) {
30 | if (shippingRates != null && shippingRates.size() > 0) {
31 |
32 | String ratesJsonString = new Gson().toJson(shippingRates,
33 | new TypeToken>() {
34 | }.getType());
35 |
36 | result.success(ratesJsonString);
37 | } else {
38 | System.out.println("No Shipping Rates available");
39 | }
40 | }
41 |
42 | @Override
43 | public void onFailure(Error error) {
44 | System.out.println("onFailure -- " + error);
45 | }
46 | });
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/GetShopInfoUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.google.gson.Gson;
4 | import com.google.gson.reflect.TypeToken;
5 | import com.jvanila.flutter.plugin.arch.PluginContext;
6 | import com.shopapp.gateway.ApiCallback;
7 | import com.shopapp.gateway.entity.Error;
8 | import com.shopapp.gateway.entity.Shop;
9 | import com.shopapp.shopify.api.ShopifyApi;
10 |
11 | import io.flutter.plugin.common.MethodCall;
12 | import io.flutter.plugin.common.MethodChannel;
13 | /**
14 | * Created by pragna on 24/09/18
15 | */
16 | public class GetShopInfoUseCase extends ShopifyCallUseCase {
17 |
18 | public GetShopInfoUseCase(PluginContext pluginContext) {
19 | super(pluginContext);
20 | }
21 |
22 | @Override
23 | protected void call(MethodCall input, final MethodChannel.Result result) {
24 | mPluginContext.api.instance.getShopInfo(new ApiCallback() {
25 | @Override
26 | public void onResult(Shop shop) {
27 | if (shop != null) {
28 |
29 | String shopJsonString = new Gson().toJson(shop,
30 | new TypeToken() {
31 | }.getType());
32 |
33 | result.success(shopJsonString);
34 | }
35 | }
36 |
37 | @Override
38 | public void onFailure(Error error) {
39 | System.out.println("onFailure -- " + error);
40 | result.error("GetShopInfoUseCase", error.getMessage(), error);
41 | }
42 | });
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/InitializeUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.shopify.api.ShopifyApi;
5 |
6 | import io.flutter.plugin.common.MethodCall;
7 | import io.flutter.plugin.common.MethodChannel;
8 |
9 | import static com.shopapp.shopify.constant.Constant.DEFAULT_SCHEME;
10 |
11 | /**
12 | * Created by pavan on 22/09/18
13 | */
14 | public class InitializeUseCase extends ShopifyCallUseCase {
15 |
16 | private static final String ARG_BASE_DOMAIN = "baseDomain";
17 | private static final String ARG_STORE_FRONT_ACCESS_TOKEN = "storeFrontAccessToken";
18 | private static final String ARG_API_KEY = "apiKey";
19 | private static final String ARG_API_PASSWORD = "apiPassword";
20 |
21 | public InitializeUseCase(PluginContext pluginContext) {
22 | super(pluginContext);
23 | }
24 |
25 | @Override
26 | protected void call(MethodCall input, MethodChannel.Result result) {
27 | String baseDomain = input.argument(ARG_BASE_DOMAIN);
28 | String storeFrontAccessToken = input.argument(ARG_STORE_FRONT_ACCESS_TOKEN);
29 | String apiKey = input.argument(ARG_API_KEY);
30 | String apiPassword = input.argument(ARG_API_PASSWORD);
31 |
32 | mPluginContext.api.instance = new ShopifyApi(mPluginContext.plugin.getRegistrar().context(),
33 | baseDomain, storeFrontAccessToken, apiKey, apiPassword, DEFAULT_SCHEME);
34 |
35 | result.success("mApi initialized " + mPluginContext.api.toString());
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/IsLoggedInUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 |
11 | public class IsLoggedInUseCase extends ShopifyCallUseCase {
12 | public IsLoggedInUseCase(PluginContext pluginContext) {
13 | super(pluginContext);
14 | }
15 |
16 | @Override
17 | protected void call(MethodCall input, final MethodChannel.Result result) {
18 | mPluginContext.api.instance.isLoggedIn(new ApiCallback() {
19 | @Override
20 | public void onResult(Boolean aBoolean) {
21 | result.success(aBoolean);
22 | }
23 |
24 | @Override
25 | public void onFailure(Error error) {
26 | System.out.println("onFailure -- " + error);
27 | result.error("IsLoggedInUseCase", error.getMessage(), error);
28 | }
29 | });
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/SetDefaultShippingAddressUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 | import kotlin.Unit;
11 |
12 | public class SetDefaultShippingAddressUseCase extends ShopifyCallUseCase {
13 |
14 | private static final String ARG_ADDRESS_ID = "addressId";
15 |
16 | public SetDefaultShippingAddressUseCase(PluginContext pluginContext) {
17 | super(pluginContext);
18 | }
19 |
20 | @Override
21 | protected void call(MethodCall input, final MethodChannel.Result result) {
22 | String addressId = input.argument(ARG_ADDRESS_ID);
23 | mPluginContext.api.instance.setDefaultShippingAddress(addressId, new ApiCallback() {
24 | @Override
25 | public void onResult(Unit unit) {
26 | result.success(true);
27 | }
28 |
29 | @Override
30 | public void onFailure(Error error) {
31 | System.out.println("onFailure -- " + error);
32 | // result.success(false);
33 | result.error("SetDefaultShippingAddressUseCase", error.getMessage(), error);
34 | }
35 | });
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/ShopifyCallUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.jvanila.flutter.plugin.arch.UseCase;
5 | import com.shopapp.shopify.api.ShopifyApi;
6 |
7 | import io.flutter.plugin.common.MethodCall;
8 | import io.flutter.plugin.common.MethodChannel;
9 |
10 | /**
11 | * Created by pavan on 23/09/18
12 | */
13 | public abstract class ShopifyCallUseCase extends
14 | UseCase {
15 |
16 | public ShopifyCallUseCase(PluginContext pluginContext) {
17 | super(pluginContext);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/SignOutUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 | import kotlin.Unit;
11 |
12 | public class SignOutUseCase extends ShopifyCallUseCase {
13 | public SignOutUseCase(PluginContext pluginContext) {
14 | super(pluginContext);
15 | }
16 |
17 | @Override
18 | protected void call(MethodCall input, final MethodChannel.Result result) {
19 | mPluginContext.api.instance.signOut(new ApiCallback() {
20 | @Override
21 | public void onResult(Unit unit) {
22 | result.success(true);
23 | }
24 |
25 | @Override
26 | public void onFailure(Error error) {
27 | System.out.println("onFailure -- " + error);
28 | // result.success(false);
29 | result.error("SignOutUseCase", error.getMessage(), error);
30 | }
31 | });
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/android/src/main/java/com/jvanila/flutter/shopify/usecases/UpdateCustomerSettingsUseCase.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.flutter.shopify.usecases;
2 |
3 | import com.jvanila.flutter.plugin.arch.PluginContext;
4 | import com.shopapp.gateway.ApiCallback;
5 | import com.shopapp.gateway.entity.Error;
6 | import com.shopapp.shopify.api.ShopifyApi;
7 |
8 | import io.flutter.plugin.common.MethodCall;
9 | import io.flutter.plugin.common.MethodChannel;
10 | import kotlin.Unit;
11 |
12 | public class UpdateCustomerSettingsUseCase extends ShopifyCallUseCase {
13 |
14 | private static final String ARG_IS_ACCEPT_MARKETING = "isAcceptMarketing";
15 |
16 | public UpdateCustomerSettingsUseCase(PluginContext pluginContext) {
17 | super(pluginContext);
18 | }
19 |
20 | @Override
21 | protected void call(MethodCall input, final MethodChannel.Result result) {
22 | boolean isAcceptMarketing = input.argument(ARG_IS_ACCEPT_MARKETING);
23 | mPluginContext.api.instance.updateCustomerSettings(isAcceptMarketing, new ApiCallback() {
24 | @Override
25 | public void onResult(Unit unit) {
26 | result.success(true);
27 | }
28 |
29 | @Override
30 | public void onFailure(Error error) {
31 | System.out.println("onFailure -- " + error);
32 | result.error("UpdateCustomerSettingsUseCase", error.getMessage(), error);
33 | }
34 | });
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/example/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | .dart_tool/
3 |
4 | .packages
5 | .pub/
6 |
7 | build/
8 |
9 | .flutter-plugins
10 |
--------------------------------------------------------------------------------
/example/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/example/README.md:
--------------------------------------------------------------------------------
1 | # shopify_example
2 |
3 | Demonstrates how to use the shopify plugin.
4 |
5 | ## Getting Started
6 |
7 | For help getting started with Flutter, view our online
8 | [documentation](https://flutter.io/).
9 |
--------------------------------------------------------------------------------
/example/android/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | *.class
3 | .gradle
4 | /local.properties
5 | /.idea/workspace.xml
6 | /.idea/libraries
7 | .DS_Store
8 | /build
9 | /captures
10 | GeneratedPluginRegistrant.java
11 |
--------------------------------------------------------------------------------
/example/android/.idea/caches/build_file_checksums.ser:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/android/.idea/caches/build_file_checksums.ser
--------------------------------------------------------------------------------
/example/android/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/example/android/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
25 |
26 |
--------------------------------------------------------------------------------
/example/android/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/android/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/example/android/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/example/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | apply plugin: 'com.android.application'
15 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
16 |
17 | android {
18 | compileSdkVersion 28
19 |
20 | lintOptions {
21 | disable 'InvalidPackage'
22 | }
23 |
24 | defaultConfig {
25 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
26 | applicationId "com.jvanila.flutter.shopifyexample"
27 | minSdkVersion 19
28 | targetSdkVersion 28
29 | versionCode 1
30 | versionName "1.0"
31 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
32 | }
33 |
34 | buildTypes {
35 | release {
36 | // TODO: Add your own signing config for the release build.
37 | // Signing with the debug keys for now, so `flutter run --release` works.
38 | signingConfig signingConfigs.debug
39 | }
40 | }
41 | compileOptions {
42 | sourceCompatibility JavaVersion.VERSION_1_8
43 | targetCompatibility JavaVersion.VERSION_1_8
44 | }
45 | }
46 |
47 | flutter {
48 | source '../..'
49 | }
50 |
51 | dependencies {
52 | testImplementation 'junit:junit:4.12'
53 | androidTestImplementation 'androidx.test:runner:1.1.1'
54 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
55 | }
56 |
--------------------------------------------------------------------------------
/example/android/app/src/main/java/com/jvanila/shopifyexample/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.jvanila.shopifyexample;
2 |
3 | import android.os.Bundle;
4 | import io.flutter.app.FlutterActivity;
5 | import io.flutter.plugins.GeneratedPluginRegistrant;
6 |
7 | public class MainActivity extends FlutterActivity {
8 | @Override
9 | protected void onCreate(Bundle savedInstanceState) {
10 | super.onCreate(savedInstanceState);
11 | GeneratedPluginRegistrant.registerWith(this);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/example/android/app/src/main/res/xml/network_security_config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/example/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | # Disables R8 for all modules.
3 | android.enableR8 = false
4 |
5 | android.useAndroidX=true
6 | android.enableJetifier=true
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/example/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Sat Apr 27 16:53:23 IST 2019
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
7 |
--------------------------------------------------------------------------------
/example/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app', ':shopifylibrary', ':gateway'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | if(name.equals("shopify")){
16 | include ':shopifylibrary'
17 | project(':shopifylibrary').projectDir = new File("$pluginDirectory/library/shopifylibrary")
18 | include ':gateway'
19 | project(':gateway').projectDir = new File("$pluginDirectory/library/gateway")
20 | println "############################# name :shopifylibrary"
21 | println "############################# pluginDirectory :$pluginDirectory/library/shopifylibrary"
22 | println "############################# name :gateway"
23 | println "############################# pluginDirectory :$pluginDirectory/library/gateway"
24 | }
25 | println "############################# name :$name"
26 | println "############################# pluginDirectory :$pluginDirectory"
27 | }
28 |
--------------------------------------------------------------------------------
/example/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/app.flx
37 | /Flutter/app.zip
38 | /Flutter/flutter_assets/
39 | /Flutter/App.framework
40 | /Flutter/Flutter.framework
41 | /Flutter/Generated.xcconfig
42 | /ServiceDefinitions.json
43 |
44 | Pods/
45 | .symlinks/
46 |
--------------------------------------------------------------------------------
/example/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 8.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"
2 | #include "Generated.xcconfig"
3 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.h:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 |
4 | @interface AppDelegate : FlutterAppDelegate
5 |
6 | @end
7 |
--------------------------------------------------------------------------------
/example/ios/Runner/AppDelegate.m:
--------------------------------------------------------------------------------
1 | #include "AppDelegate.h"
2 | #include "GeneratedPluginRegistrant.h"
3 | #import "Runner-Swift.h"
4 |
5 | @implementation AppDelegate
6 |
7 | - (BOOL)application:(UIApplication *)application
8 | didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
9 | [GeneratedPluginRegistrant registerWithRegistry:self];
10 |
11 | // Override point for customization after application launch.
12 | return [super application:application didFinishLaunchingWithOptions:launchOptions];
13 | }
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/example/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/example/ios/Runner/HelloSwift.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HelloSwift.swift
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | import Foundation
10 |
11 | class HelloSwift : NSObject {
12 |
13 | func sayHello() {
14 | print("Hello")
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/example/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | shopify_example
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/example/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 |
--------------------------------------------------------------------------------
/example/ios/Runner/main.m:
--------------------------------------------------------------------------------
1 | #import
2 | #import
3 | #import "AppDelegate.h"
4 |
5 | int main(int argc, char* argv[]) {
6 | @autoreleasepool {
7 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/example/lib/app.dart:
--------------------------------------------------------------------------------
1 | library app;
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:shopify_example/webview_widget.dart';
5 |
6 | export 'application.dart';
7 | export 'tow_injector.dart';
8 |
9 | routeMap() {
10 | return {
11 | '/base': (context) => new WebViewExample(context),
12 | };
13 | }
--------------------------------------------------------------------------------
/example/lib/application.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:jvanila_flutter/jvanila.dart';
3 | import 'package:shopify_example/webview_widget.dart';
4 |
5 | import 'app.dart';
6 | import 'tow_injector.dart';
7 |
8 | class TowApplication extends ApplicationView {
9 |
10 | TowApplication({routes}) : super(routes: routes);
11 |
12 | @override
13 | Injector newInjector(ApplicationContext context) {
14 | return new TowInjector(context);
15 | }
16 |
17 | @override
18 | void setHomeView() {
19 | if (widgetTree['home'] == null) {
20 | widgetTree['home'] = new WebViewExample(context);
21 | }
22 | else {
23 | WebViewExample home = widgetTree['home'];
24 | home.refresh();
25 | }
26 | }
27 |
28 | @override
29 | loadView(context) {
30 | return new MaterialApp(
31 | home: widgetTree["home"], routes: routes,
32 | theme: ThemeData(primaryColor: Colors.orange));
33 | }
34 | }
--------------------------------------------------------------------------------
/example/lib/tow_injector.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 |
3 | class TowInjector extends Injector {
4 |
5 | TowInjector(ApplicationContext context) : super(context);
6 |
7 | RepositoryFactory newRepoFactory() {
8 | return null;//new TowRepoFactory();
9 | }
10 |
11 | @override
12 | void injectApisOnAppCreate() {
13 | super.injectApisOnAppCreate();
14 | /*context.apis['EcommerceApi'] = new GoFrugal(context, domainPath: 'TBF',
15 | authToken: 'TBF',);*/
16 |
17 | // context.apis = new Map();
18 | // context.apis['EcommerceApi'] = new MockCommerceApi();
19 | }
20 | }
--------------------------------------------------------------------------------
/example/lib/web_view.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 | import 'package:shopify/model/customer.dart';
3 |
4 | abstract class IWebView extends IPresentableView {
5 |
6 | void setCustomerInfo(Customer customer);
7 |
8 | void setLoading(bool isLoading);
9 |
10 | void setAccessToken(String token);
11 | }
--------------------------------------------------------------------------------
/example/lib/web_view_presenter.dart:
--------------------------------------------------------------------------------
1 | import 'dart:async';
2 |
3 | import 'package:jvanila_flutter/jvanila.dart';
4 | import 'package:shopify/domain/initialize_params.dart';
5 | import 'package:shopify/shopify.dart';
6 | import 'package:shopify_example/web_view.dart';
7 | import 'package:shopify/model/customer.dart';
8 |
9 | class WebViewPresenter extends Presenter {
10 | WebViewPresenter(IWebView view) : super(view);
11 |
12 | bool isFirstLoad = true;
13 |
14 | @override
15 | void onReady() {
16 |
17 | if (isFirstLoad) {
18 | view.setLoading(isFirstLoad);
19 | initShopify();
20 | }
21 | }
22 |
23 | Future initShopify() async {
24 | ShopifyInitializeParams params = new ShopifyInitializeParams();
25 | params.domainName = "porganicworld.myshopify.com";
26 | params.accessToken = "62761bc137e3dac4c66d1d1a93d8dab3";
27 | params.apiKey = "1e5f1c6facb67ef0bf9e0c4af642d192";
28 | params.apiPassword = "5c3061bb2e053642fc1422409ccbb89e";
29 | await Shopify.initialize(params);
30 |
31 | signIn();
32 | }
33 |
34 | Future signIn() async {
35 | await Shopify.signIn("imei355923070770619@gmail.com", "bFppaybqvWaD6CZdAtL5T7FN1XF2");
36 | String token = await Shopify.getAccessToken();
37 | view.setAccessToken(token);
38 | getCustomer();
39 | }
40 |
41 | Future getCustomer() async {
42 | Customer customer = await Shopify.getCustomer();
43 | isFirstLoad = false;
44 | view.setLoading(isFirstLoad);
45 | view.setCustomerInfo(customer);
46 | view.refresh();
47 | }
48 |
49 | }
--------------------------------------------------------------------------------
/example/lib/webview_main.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 | import 'package:shopify_example/app.dart';
3 | import 'package:shopify_example/application.dart';
4 |
5 | void main() => runApplication(new TowApplication(routes: routeMap()));
6 |
--------------------------------------------------------------------------------
/example/shopify_example.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/example/shopify_example_android.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/example/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | // To perform an interaction with a widget in your test, use the WidgetTester utility that Flutter
3 | // provides. For example, you can send tap and scroll gestures. You can also use WidgetTester to
4 | // find child widgets in the widget tree, read text, and verify that the values of widget properties
5 | // are correct.
6 |
7 | import 'package:flutter/material.dart';
8 | import 'package:flutter_test/flutter_test.dart';
9 |
10 | //import 'package:shopify_example/main.dart';
11 |
12 | void main() {
13 | /*testWidgets('Verify Platform version', (WidgetTester tester) async {
14 | // Build our app and trigger a frame.
15 | await tester.pumpWidget(new MyApp());
16 |
17 | // Verify that platform version is retrieved.
18 | expect(
19 | find.byWidgetPredicate(
20 | (Widget widget) =>
21 | widget is Text && widget.data.startsWith('Running on:'),
22 | ),
23 | findsOneWidget);
24 | });*/
25 | }
26 |
--------------------------------------------------------------------------------
/ios/.gitignore:
--------------------------------------------------------------------------------
1 | .idea/
2 | .vagrant/
3 | .sconsign.dblite
4 | .svn/
5 |
6 | .DS_Store
7 | *.swp
8 | profile
9 |
10 | DerivedData/
11 | build/
12 | GeneratedPluginRegistrant.h
13 | GeneratedPluginRegistrant.m
14 |
15 | .generated/
16 |
17 | *.pbxuser
18 | *.mode1v3
19 | *.mode2v3
20 | *.perspectivev3
21 |
22 | !default.pbxuser
23 | !default.mode1v3
24 | !default.mode2v3
25 | !default.perspectivev3
26 |
27 | xcuserdata
28 |
29 | *.moved-aside
30 |
31 | *.pyc
32 | *sync/
33 | Icon?
34 | .tags*
35 |
36 | /Flutter/Generated.xcconfig
37 |
--------------------------------------------------------------------------------
/ios/Assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/ios/Assets/.gitkeep
--------------------------------------------------------------------------------
/ios/Classes/ShopifyPlugin.h:
--------------------------------------------------------------------------------
1 | //
2 | // ShopifyPlugin.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "Plugin.h"
10 | @class Plugin;
11 |
12 | @interface ShopifyPlugin : Plugin
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/Classes/ShopifyPlugin.m:
--------------------------------------------------------------------------------
1 | //
2 | // ShopifyPlugin.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "ShopifyPlugin.h"
10 | #import "ShopifyConstants.h"
11 | #import "ClosePluginUseCase.h"
12 | #import "GetPlatformVersionUseCase.h"
13 |
14 | @implementation ShopifyPlugin
15 |
16 | + (void)registerWithRegistrar:(NSObject*)registrar {
17 | ShopifyPlugin *plugin = [[ShopifyPlugin alloc]
18 | initWith:@"shopify"
19 | withRegistrar:registrar
20 | withApi:[[Api alloc] init]];
21 | [plugin description];//patch fix
22 | }
23 |
24 | -(void)onCreateUseCasesWith:(UseCaseProvider *)provider
25 | {
26 | [provider registerUseCase:@"close"
27 | with:[[ClosePluginUseCase alloc] initWith:self.mPluginContext]];
28 | [provider registerUseCase:@"getPlatformVersion"
29 | with:[[GetPlatformVersionUseCase alloc] initWith:self.mPluginContext]];
30 | }
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/ios/Classes/UseCases/ClosePluginUseCase.h:
--------------------------------------------------------------------------------
1 | //
2 | // ClosePluginUseCase.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "UseCase.h"
11 |
12 | @interface ClosePluginUseCase : UseCase
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/Classes/UseCases/ClosePluginUseCase.m:
--------------------------------------------------------------------------------
1 | //
2 | // ClosePluginUseCase.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "ClosePluginUseCase.h"
10 |
11 | @implementation ClosePluginUseCase
12 |
13 | -(void)triggerWithMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
14 | [self.mContext.plugin onDestroy];
15 | result(@"success");
16 | }
17 |
18 | @end
19 |
--------------------------------------------------------------------------------
/ios/Classes/UseCases/GetPlatformVersionUseCase.h:
--------------------------------------------------------------------------------
1 | //
2 | // GetPlatformVersionUseCase.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "UseCase.h"
10 | @class UseCase;
11 |
12 | @interface GetPlatformVersionUseCase : UseCase
13 |
14 | @end
15 |
--------------------------------------------------------------------------------
/ios/Classes/UseCases/GetPlatformVersionUseCase.m:
--------------------------------------------------------------------------------
1 | //
2 | // GetPlatformVersionUseCase.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "GetPlatformVersionUseCase.h"
10 |
11 | @implementation GetPlatformVersionUseCase
12 |
13 | -(void)triggerWithMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
14 | result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
15 | }
16 |
17 | @end
18 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/Api.h:
--------------------------------------------------------------------------------
1 | //
2 | // Api.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface Api : NSObject
12 |
13 | @property (nonatomic, strong) id instance;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/Api.m:
--------------------------------------------------------------------------------
1 | //
2 | // Api.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "Api.h"
10 |
11 | @implementation Api
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/Plugin.h:
--------------------------------------------------------------------------------
1 | //
2 | // Plugin.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "Api.h"
12 | #import "UseCaseProvider.h"
13 |
14 | @class Api;
15 | @class UseCaseProvider;
16 | @class PluginContext;
17 |
18 | @interface Plugin : NSObject
19 |
20 | @property(nonatomic, strong) UseCaseProvider *mUseCaseProvider;
21 | @property(nonatomic, strong) PluginContext *mPluginContext;
22 |
23 | -(id)initWith:(NSString *)name withRegistrar:(nonnull NSObject *)registrar withApi:(Api *)api;
24 |
25 | -(void)onCreateUseCasesWith:(UseCaseProvider *)provider;
26 |
27 | -(void)onDestroy;
28 |
29 | @end
30 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/Plugin.m:
--------------------------------------------------------------------------------
1 | //
2 | // Plugin.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "Plugin.h"
10 | #import "UseCaseProvider.h"
11 |
12 | @implementation Plugin
13 |
14 | + (void)registerWithRegistrar:(nonnull NSObject *)registrar {
15 | //Subclasses must override this
16 | }
17 |
18 | -(id)initWith:(NSString *)name withRegistrar:(nonnull NSObject *)registrar withApi:(Api *)api {
19 | self = [super init];
20 | if (self)
21 | {
22 | FlutterMethodChannel* channel = [FlutterMethodChannel
23 | methodChannelWithName:name
24 | binaryMessenger:[registrar messenger]];
25 | [registrar addMethodCallDelegate:self channel:channel];
26 |
27 | _mPluginContext = [[PluginContext alloc] init];
28 | _mPluginContext.api = api;
29 | _mPluginContext.plugin = self;
30 |
31 | _mUseCaseProvider = [[UseCaseProvider alloc] init];
32 | [self onCreateUseCasesWith:_mUseCaseProvider];
33 | }
34 | return self;
35 | }
36 |
37 | -(void)onCreateUseCasesWith:(UseCaseProvider *)provider {
38 | }
39 |
40 | - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
41 | FlutterResult asyncResult = ^(id res) {
42 | dispatch_async(dispatch_get_main_queue(), ^{
43 | result(res);
44 | });
45 | };
46 |
47 | [[self.mUseCaseProvider of:call.method] executeWithMethodCall:call result:asyncResult];
48 | }
49 |
50 | -(void)onDestroy {
51 |
52 | }
53 |
54 | @end
55 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/PluginContext.h:
--------------------------------------------------------------------------------
1 | //
2 | // PluginContext.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Api.h"
11 | #import "Plugin.h"
12 |
13 | @class Api;
14 | @class Plugin;
15 |
16 | @interface PluginContext : NSObject
17 |
18 | @property (nonatomic, retain) Api *api;
19 | @property (nonatomic, retain) Plugin *plugin;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/PluginContext.m:
--------------------------------------------------------------------------------
1 | //
2 | // PluginContext.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "PluginContext.h"
10 |
11 | @implementation PluginContext
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/UseCase.h:
--------------------------------------------------------------------------------
1 | //
2 | // UseCase.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "PluginContext.h"
12 |
13 | @class PluginContext;
14 |
15 | @interface UseCase : NSObject
16 |
17 | @property(nonatomic, retain) PluginContext *mContext;
18 |
19 | -(id)initWith:(PluginContext *)context;
20 | -(void)executeWithMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
21 | -(void)triggerWithMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result;
22 |
23 | @end
24 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/UseCase.m:
--------------------------------------------------------------------------------
1 | //
2 | // UseCase.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "UseCase.h"
10 |
11 | @implementation UseCase
12 |
13 | -(id)initWith:(PluginContext *)context
14 | {
15 | self = [super init];
16 | if (self)
17 | {
18 | _mContext = context;
19 | }
20 | return self;
21 | }
22 |
23 | -(void)executeWithMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
24 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
25 | [self triggerWithMethodCall:call result:result];
26 | });
27 | }
28 |
29 | - (void)triggerWithMethodCall:(FlutterMethodCall *)call result:(FlutterResult)result {
30 | //override
31 | }
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/UseCaseProvider.h:
--------------------------------------------------------------------------------
1 | //
2 | // UseCaseProvider.h
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "UseCase.h"
11 |
12 | @class UseCase;
13 |
14 | @interface UseCaseProvider : NSObject
15 |
16 | -(void)registerUseCase:(NSString *)clazz with:(UseCase *)usecase;
17 |
18 | -(UseCase *)of:(NSString *)clazz;
19 |
20 | @end
21 |
--------------------------------------------------------------------------------
/ios/Classes/jVanila/UseCaseProvider.m:
--------------------------------------------------------------------------------
1 | //
2 | // UseCaseProvider.m
3 | // Runner
4 | //
5 | // Created by pavan on 29/03/19.
6 | // Copyright © 2019 The Chromium Authors. All rights reserved.
7 | //
8 |
9 | #import "UseCaseProvider.h"
10 |
11 | @interface UseCaseProvider()
12 |
13 | @property(nonatomic, retain) NSMutableDictionary *mRegistry;
14 |
15 | @end
16 |
17 | @implementation UseCaseProvider
18 |
19 | -(id)init
20 | {
21 | self = [super init];
22 | if (self)
23 | {
24 | _mRegistry = [[NSMutableDictionary alloc] init];
25 | }
26 | return self;
27 | }
28 |
29 | -(void)registerUseCase:(NSString *)clazz with:(UseCase *)usecase {
30 | [_mRegistry setValue:usecase forKey:clazz];
31 | }
32 |
33 | - (UseCase *)of:(NSString *)clazz {
34 | return [_mRegistry valueForKey:clazz];
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/ios/shopify.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html
3 | #
4 | Pod::Spec.new do |s|
5 | s.name = 'shopify'
6 | s.version = '0.0.1'
7 | s.summary = 'A new Flutter plugin.'
8 | s.description = <<-DESC
9 | A new Flutter plugin.
10 | DESC
11 | s.homepage = 'http://example.com'
12 | s.license = { :file => '../LICENSE' }
13 | s.author = { 'Your Company' => 'email@example.com' }
14 | s.source = { :path => '.' }
15 | s.source_files = 'Classes/**/*'
16 | s.public_header_files = 'Classes/**/*.h'
17 | s.dependency 'Flutter'
18 |
19 | s.ios.deployment_target = '8.0'
20 | end
21 |
22 |
--------------------------------------------------------------------------------
/lib/domain/initialize_params.dart:
--------------------------------------------------------------------------------
1 | class ShopifyInitializeParams {
2 | String domainName;
3 | String accessToken;
4 | String apiPassword;
5 | String apiKey;
6 | }
--------------------------------------------------------------------------------
/lib/model/address.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'address.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Address _$AddressFromJson(Map json) {
10 | return new Address(
11 | id: json['id'] as String,
12 | address: json['address'] as String,
13 | secondAddress: json['secondAddress'] as String,
14 | city: json['city'] as String,
15 | country: json['country'] as String,
16 | firstName: json['firstName'] as String,
17 | lastName: json['lastName'] as String,
18 | zip: json['zip'] as String,
19 | company: json['company'] as String,
20 | phone: json['phone'] as String)
21 | ..crudOperation = json['crudOperation'] as String
22 | ..state = json['state'] as String;
23 | }
24 |
25 | abstract class _$AddressSerializerMixin {
26 | String get crudOperation;
27 | String get id;
28 | String get address;
29 | String get secondAddress;
30 | String get city;
31 | String get state;
32 | String get country;
33 | String get firstName;
34 | String get lastName;
35 | String get zip;
36 | String get company;
37 | String get phone;
38 | Map toJson() => {
39 | 'crudOperation': crudOperation,
40 | 'id': id,
41 | 'address': address,
42 | 'secondAddress': secondAddress,
43 | 'city': city,
44 | 'state': state,
45 | 'country': country,
46 | 'firstName': firstName,
47 | 'lastName': lastName,
48 | 'zip': zip,
49 | 'company': company,
50 | 'phone': phone
51 | };
52 | }
53 |
--------------------------------------------------------------------------------
/lib/model/author.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'author.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Author _$AuthorFromJson(Map json) {
10 | return new Author(
11 | firstName: json['firstName'] as String,
12 | lastName: json['lastName'] as String,
13 | fullName: json['fullName'] as String,
14 | email: json['email'] as String,
15 | bio: json['bio'] as String)
16 | ..crudOperation = json['crudOperation'] as String;
17 | }
18 |
19 | abstract class _$AuthorSerializerMixin {
20 | String get crudOperation;
21 | String get firstName;
22 | String get lastName;
23 | String get fullName;
24 | String get email;
25 | String get bio;
26 | Map toJson() => {
27 | 'crudOperation': crudOperation,
28 | 'firstName': firstName,
29 | 'lastName': lastName,
30 | 'fullName': fullName,
31 | 'email': email,
32 | 'bio': bio
33 | };
34 | }
35 |
--------------------------------------------------------------------------------
/lib/model/card.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 |
3 | class CardDetails extends DataObject {
4 | String firstName;
5 | String lastName;
6 | String cardNumber;
7 | String expireMonth;
8 | String expireYear;
9 | String verificationCode;
10 |
11 | CardDetails({this.firstName, this.lastName, this.cardNumber, this.expireMonth,
12 | this.expireYear, this.verificationCode});
13 |
14 | @override
15 | int get hashCode => _getHashCode();
16 |
17 | int _getHashCode() {
18 | int result = firstName.hashCode;
19 |
20 | result = 31 * result + lastName.hashCode;
21 | result = 31 * result + cardNumber.hashCode;
22 | result = 31 * result + expireMonth.hashCode;
23 | result = 31 * result + expireYear.hashCode;
24 | result = 31 * result + verificationCode.hashCode;
25 | return result;
26 | }
27 |
28 | @override
29 | bool operator ==(object) {
30 |
31 | if (this == object) {
32 | return true;
33 | }
34 | if (object == null || toString() != object.toString()) {
35 | return false;
36 | }
37 |
38 | CardDetails card = object;
39 |
40 | if (firstName != card.firstName) return false;
41 | if (lastName != card.lastName) return false;
42 | if (cardNumber != card.cardNumber)
43 | return false;
44 | if (expireMonth != card.expireMonth) return false;
45 | if (expireYear != card.expireYear) return false;
46 | if (verificationCode != card.verificationCode) return false;
47 |
48 | return true;
49 | }
50 |
51 | String toString() {
52 | return "Card{ " +
53 | " firstName ='" + firstName + '\'' +
54 | ", lastName ='" + lastName + '\'' +
55 | ", cardNumber ='" + cardNumber + '\'' +
56 | ", expireMonth ='" + expireMonth + '\'' +
57 | ", expireYear ='" + expireYear + '\'' +
58 | ", verificationCode ='" + verificationCode + '\'' +
59 | '}';
60 | }
61 | }
--------------------------------------------------------------------------------
/lib/model/card_type.dart:
--------------------------------------------------------------------------------
1 | //enum
2 | enum CardType {
3 | VISA,
4 | MASTER_CARD,
5 | AMERICAN_EXPRESS
6 | }
7 |
8 | /*
9 | enum class CardType(val nameRes: Int, val logoRes: Int) {
10 | VISA(R.string.visa, R.drawable.ic_visa),
11 | MASTER_CARD(R.string.mastercard, R.drawable.ic_master_card),
12 | AMERICAN_EXPRESS(R.string.american_express, R.drawable.ic_amex),
13 | DINERS_CLUB(R.string.diners_club, R.drawable.ic_dc_card),
14 | DISCOVER(R.string.discover, R.drawable.ic_discover),
15 | JCB(R.string.jcb, R.drawable.ic_jcb_card)
16 | }*/
17 |
--------------------------------------------------------------------------------
/lib/model/cart_product.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'cart_product.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | CartProduct _$CartProductFromJson(Map json) {
10 | return new CartProduct(
11 | productVariant: new ProductVariant.fromJson(
12 | json['productVariant'] as Map),
13 | title: json['title'] as String,
14 | currency: json['currency'] as String,
15 | quantity: json['quantity'] as int)
16 | ..crudOperation = json['crudOperation'] as String;
17 | }
18 |
19 | abstract class _$CartProductSerializerMixin {
20 | String get crudOperation;
21 | ProductVariant get productVariant;
22 | String get title;
23 | String get currency;
24 | int get quantity;
25 | Map toJson() => {
26 | 'crudOperation': crudOperation,
27 | 'productVariant': productVariant,
28 | 'title': title,
29 | 'currency': currency,
30 | 'quantity': quantity
31 | };
32 | }
33 |
--------------------------------------------------------------------------------
/lib/model/category.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'category.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Category _$CategoryFromJson(Map json) {
10 | return new Category(
11 | id: json['id'] as String,
12 | title: json['title'] as String,
13 | categoryDescription: json['categoryDescription'] as String,
14 | additionalDescription: json['additionalDescription'] as String,
15 | updatedAt: json['updatedAt'] as String,
16 | productList: (json['productList'] as List)
17 | .map((e) => new Product.fromJson(e as Map))
18 | .toList(),
19 | paginationValue: json['paginationValue'] as String)
20 | ..crudOperation = json['crudOperation'] as String
21 | ..image = new ImageDTO.fromJson(json['image'] as Map);
22 | }
23 |
24 | abstract class _$CategorySerializerMixin {
25 | String get crudOperation;
26 | String get id;
27 | String get title;
28 | String get categoryDescription;
29 | String get additionalDescription;
30 | ImageDTO get image;
31 | String get updatedAt;
32 | List get productList;
33 | String get paginationValue;
34 | Map toJson() => {
35 | 'crudOperation': crudOperation,
36 | 'id': id,
37 | 'title': title,
38 | 'categoryDescription': categoryDescription,
39 | 'additionalDescription': additionalDescription,
40 | 'image': image,
41 | 'updatedAt': updatedAt,
42 | 'productList': productList,
43 | 'paginationValue': paginationValue
44 | };
45 | }
46 |
--------------------------------------------------------------------------------
/lib/model/checkout.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'checkout.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Checkout _$CheckoutFromJson(Map json) {
10 | return new Checkout(
11 | checkoutId: json['checkoutId'] as String,
12 | webUrl: json['webUrl'] as String,
13 | requiresShipping: json['requiresShipping'] as bool,
14 | subtotalPrice: (json['subtotalPrice'] as num).toDouble(),
15 | totalPrice: (json['totalPrice'] as num).toDouble(),
16 | taxPrice: (json['taxPrice'] as num).toDouble(),
17 | currency: json['currency'] as String)
18 | ..crudOperation = json['crudOperation'] as String;
19 | }
20 |
21 | abstract class _$CheckoutSerializerMixin {
22 | String get crudOperation;
23 | String get checkoutId;
24 | String get webUrl;
25 | bool get requiresShipping;
26 | double get subtotalPrice;
27 | double get totalPrice;
28 | double get taxPrice;
29 | String get currency;
30 | Map toJson() => {
31 | 'crudOperation': crudOperation,
32 | 'checkoutId': checkoutId,
33 | 'webUrl': webUrl,
34 | 'requiresShipping': requiresShipping,
35 | 'subtotalPrice': subtotalPrice,
36 | 'totalPrice': totalPrice,
37 | 'taxPrice': taxPrice,
38 | 'currency': currency
39 | };
40 | }
41 |
--------------------------------------------------------------------------------
/lib/model/country.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'country.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Country _$CountryFromJson(Map json) {
10 | return new Country(
11 | id: json['id'] as int,
12 | code: json['code'] as String,
13 | name: json['name'] as String,
14 | states: (json['states'] as List)
15 | .map((e) => new State.fromJson(e as Map))
16 | .toList())
17 | ..crudOperation = json['crudOperation'] as String;
18 | }
19 |
20 | abstract class _$CountrySerializerMixin {
21 | String get crudOperation;
22 | int get id;
23 | String get code;
24 | String get name;
25 | List get states;
26 | Map toJson() => {
27 | 'crudOperation': crudOperation,
28 | 'id': id,
29 | 'code': code,
30 | 'name': name,
31 | 'states': states
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/lib/model/customer.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'customer.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Customer _$CustomerFromJson(Map json) {
10 | return new Customer(
11 | id: json['id'] as String,
12 | email: json['email'] as String,
13 | firstName: json['firstName'] as String,
14 | lastName: json['lastName'] as String,
15 | phone: json['phone'] as String,
16 | isAcceptsMarketing: json['isAcceptsMarketing'] as bool,
17 | addressList: (json['addressList'] as List)
18 | .map((e) => new Address.fromJson(e as Map))
19 | .toList(),
20 | defaultAddress:
21 | new Address.fromJson(json['defaultAddress'] as Map))
22 | ..crudOperation = json['crudOperation'] as String;
23 | }
24 |
25 | abstract class _$CustomerSerializerMixin {
26 | String get crudOperation;
27 | String get id;
28 | String get email;
29 | String get firstName;
30 | String get lastName;
31 | String get phone;
32 | bool get isAcceptsMarketing;
33 | List get addressList;
34 | Address get defaultAddress;
35 | Map toJson() => {
36 | 'crudOperation': crudOperation,
37 | 'id': id,
38 | 'email': email,
39 | 'firstName': firstName,
40 | 'lastName': lastName,
41 | 'phone': phone,
42 | 'isAcceptsMarketing': isAcceptsMarketing,
43 | 'addressList': addressList,
44 | 'defaultAddress': defaultAddress
45 | };
46 | }
47 |
--------------------------------------------------------------------------------
/lib/model/delivery_info.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 |
3 | class DeliveryInfo extends DataObject {
4 |
5 | double minDeliveryCharges;
6 | List availableDeliverySlots;
7 | int numberOfShipments;
8 | String defaultSelectedDeliverySlot;
9 | double minPriceForFreeDelivery;
10 | }
--------------------------------------------------------------------------------
/lib/model/error.dart:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/pavan2you/flutter-shopify/7b171e75d7059d5c1806032fb0b411b01af19200/lib/model/error.dart
--------------------------------------------------------------------------------
/lib/model/image.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 |
3 | import 'package:json_annotation/json_annotation.dart';
4 | import 'package:jvanila_flutter/jvanila.dart';
5 |
6 | part 'image.g.dart';
7 |
8 | @JsonSerializable(nullable: false)
9 | class ImageDTO extends DataObject with _$ImageDTOSerializerMixin {
10 | String id;
11 | String src;
12 | String alt;
13 |
14 | ImageDTO({this.id, this.src, this.alt});
15 |
16 | factory ImageDTO.fromJson(Map json) => _$ImageDTOFromJson(json);
17 |
18 | @override
19 | String jsonify() {
20 | return new JsonEncoder().convert(toJson());
21 | }
22 |
23 | @override
24 | Map toMap([Map map]) {
25 | var map = new Map();
26 | map["id"] = id;
27 | map["src"] = src;
28 | map["alt"] = alt;
29 | return map;
30 | }
31 |
32 | @override
33 | int get hashCode => getHashCode();
34 |
35 | int getHashCode() {
36 | int result = id.hashCode;
37 |
38 | result = 31 * result + src.hashCode;
39 | result = 31 * result + (alt != null ? alt.hashCode : 0);
40 | return result;
41 | }
42 |
43 | @override
44 | bool operator ==(object) {
45 |
46 | if (this == object) {
47 | return true;
48 | }
49 | if (object == null || toString() != object.toString()) {
50 | return false;
51 | }
52 |
53 | ImageDTO image = object;
54 |
55 | if (id != image.id) return false;
56 | if (src != image.src) return false;
57 | if (alt != image?.alt)
58 | return false;
59 |
60 | return true;
61 | }
62 |
63 | String toString() {
64 | return "Image{ " +
65 | " id ='" + id + '\'' +
66 | ", src ='" + src + '\'' +
67 | ", alt ='" + alt + '\'' +
68 | '}';
69 | }
70 | }
--------------------------------------------------------------------------------
/lib/model/image.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'image.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | ImageDTO _$ImageDTOFromJson(Map json) {
10 | return new ImageDTO(
11 | id: json['id'] as String,
12 | src: json['src'] as String,
13 | alt: json['alt'] as String)
14 | ..crudOperation = json['crudOperation'] as String;
15 | }
16 |
17 | abstract class _$ImageDTOSerializerMixin {
18 | String get crudOperation;
19 | String get id;
20 | String get src;
21 | String get alt;
22 | Map toJson() => {
23 | 'crudOperation': crudOperation,
24 | 'id': id,
25 | 'src': src,
26 | 'alt': alt
27 | };
28 | }
29 |
--------------------------------------------------------------------------------
/lib/model/offer_product.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 | import 'package:shopify/model/product.dart';
3 |
4 | class OfferProduct extends DataObject {
5 |
6 | Product product;
7 | double offerPrice;
8 | }
--------------------------------------------------------------------------------
/lib/model/order_product.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'order_product.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | OrderProduct _$OrderProductFromJson(Map json) {
10 | return new OrderProduct(
11 | title: json['title'] as String,
12 | productVariant: new ProductVariant.fromJson(
13 | json['productVariant'] as Map),
14 | quantity: json['quantity'] as int)
15 | ..crudOperation = json['crudOperation'] as String;
16 | }
17 |
18 | abstract class _$OrderProductSerializerMixin {
19 | String get crudOperation;
20 | String get title;
21 | ProductVariant get productVariant;
22 | int get quantity;
23 | Map toJson() => {
24 | 'crudOperation': crudOperation,
25 | 'title': title,
26 | 'productVariant': productVariant,
27 | 'quantity': quantity
28 | };
29 | }
30 |
--------------------------------------------------------------------------------
/lib/model/policy.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 | import 'dart:convert';
3 | import 'package:json_annotation/json_annotation.dart';
4 |
5 | part 'policy.g.dart';
6 |
7 | @JsonSerializable(nullable: false)
8 | class Policy extends DataObject with _$PolicySerializerMixin {
9 | String title;
10 | String body;
11 | String url;
12 |
13 | Policy({this.title, this.body, this.url});
14 |
15 | factory Policy.fromJson(Map json) => _$PolicyFromJson(json);
16 |
17 | @override
18 | String jsonify() {
19 | return new JsonEncoder().convert(toJson());
20 | }
21 |
22 | @override
23 | Map toMap([Map map]) {
24 | var map = new Map();
25 | map["title"] = title;
26 | map["body"] = body;
27 | map["url"] = url;
28 | return map;
29 | }
30 |
31 | @override
32 | int get hashCode => getHashCode();
33 |
34 | int getHashCode() {
35 | int result = title.hashCode;
36 |
37 | result = 31 * result + body.hashCode;
38 | result = 31 * result + url.hashCode;
39 | return result;
40 | }
41 |
42 | @override
43 | bool operator ==(object) {
44 |
45 | if (this == object) {
46 | return true;
47 | }
48 | if (object == null || toString() != object.toString()) {
49 | return false;
50 | }
51 |
52 | Policy policy = object;
53 |
54 | if (title != policy.title) return false;
55 | if (body != policy.body) return false;
56 | if (url != policy.url)
57 | return false;
58 |
59 | return true;
60 | }
61 |
62 |
63 | String toString() {
64 | return "Policy{ " +
65 | " title ='" + title + '\'' +
66 | ", body ='" + body + '\'' +
67 | ", url ='" + url + '\'' +
68 | '}';
69 | }
70 | }
--------------------------------------------------------------------------------
/lib/model/policy.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'policy.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Policy _$PolicyFromJson(Map json) {
10 | return new Policy(
11 | title: json['title'] as String,
12 | body: json['body'] as String,
13 | url: json['url'] as String)
14 | ..crudOperation = json['crudOperation'] as String;
15 | }
16 |
17 | abstract class _$PolicySerializerMixin {
18 | String get crudOperation;
19 | String get title;
20 | String get body;
21 | String get url;
22 | Map toJson() => {
23 | 'crudOperation': crudOperation,
24 | 'title': title,
25 | 'body': body,
26 | 'url': url
27 | };
28 | }
29 |
--------------------------------------------------------------------------------
/lib/model/product_option.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'package:jvanila_flutter/jvanila.dart';
3 | import 'package:json_annotation/json_annotation.dart';
4 |
5 | part 'product_option.g.dart';
6 |
7 | @JsonSerializable(nullable: false)
8 | class ProductOption extends DataObject with _$ProductOptionSerializerMixin {
9 | String id;
10 | String name;
11 | List values;
12 |
13 | ProductOption({this.id, this.name, this.values});
14 |
15 | factory ProductOption.fromJson(Map json) => _$ProductOptionFromJson(json);
16 |
17 | @override
18 | String jsonify() {
19 | return new JsonEncoder().convert(toJson());
20 | }
21 |
22 | @override
23 | Map toMap([Map map]) {
24 | var map = new Map();
25 | map["id"] = id;
26 | map["name"] = name;
27 | map["values"] = values;
28 | return map;
29 | }
30 |
31 | @override
32 | int get hashCode => getHashCode();
33 |
34 | int getHashCode() {
35 | int result = id.hashCode;
36 |
37 | result = 31 * result + name.hashCode;
38 | result = 31 * result + values.hashCode;
39 | return result;
40 | }
41 |
42 | @override
43 | bool operator ==(object) {
44 |
45 | if (this == object) {
46 | return true;
47 | }
48 | if (object == null || toString() != object.toString()) {
49 | return false;
50 | }
51 |
52 | ProductOption productOption = object;
53 |
54 | if (id != productOption.id) return false;
55 | if (name != productOption.name) return false;
56 | if (values != productOption.values)
57 | return false;
58 |
59 | return true;
60 | }
61 |
62 | String toString() {
63 | return "ProductOption{ " +
64 | " id ='" + id + '\'' +
65 | ", name ='" + name + '\'' +
66 | '}';
67 | }
68 | }
--------------------------------------------------------------------------------
/lib/model/product_option.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'product_option.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | ProductOption _$ProductOptionFromJson(Map json) {
10 | return new ProductOption(
11 | id: json['id'] as String,
12 | name: json['name'] as String,
13 | values: (json['values'] as List).map((e) => e as String).toList())
14 | ..crudOperation = json['crudOperation'] as String;
15 | }
16 |
17 | abstract class _$ProductOptionSerializerMixin {
18 | String get crudOperation;
19 | String get id;
20 | String get name;
21 | List get values;
22 | Map toJson() => {
23 | 'crudOperation': crudOperation,
24 | 'id': id,
25 | 'name': name,
26 | 'values': values
27 | };
28 | }
29 |
--------------------------------------------------------------------------------
/lib/model/product_variant.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'product_variant.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | ProductVariant _$ProductVariantFromJson(Map json) {
10 | return new ProductVariant(
11 | id: json['id'] as String,
12 | title: json['title'] as String,
13 | price: (json['price'] as num).toDouble(),
14 | compareAtPrice: (json['compareAtPrice'] as num).toDouble(),
15 | isAvailable: json['isAvailable'] as bool,
16 | selectedOptions: (json['selectedOptions'] as List)
17 | .map((e) => new VariantOption.fromJson(e as Map))
18 | .toList(),
19 | image: new ImageDTO.fromJson(json['image'] as Map),
20 | productImage:
21 | new ImageDTO.fromJson(json['productImage'] as Map),
22 | productId: json['productId'] as String)
23 | ..crudOperation = json['crudOperation'] as String;
24 | }
25 |
26 | abstract class _$ProductVariantSerializerMixin {
27 | String get crudOperation;
28 | String get id;
29 | String get title;
30 | double get price;
31 | double get compareAtPrice;
32 | bool get isAvailable;
33 | List get selectedOptions;
34 | ImageDTO get image;
35 | ImageDTO get productImage;
36 | String get productId;
37 | Map toJson() => {
38 | 'crudOperation': crudOperation,
39 | 'id': id,
40 | 'title': title,
41 | 'price': price,
42 | 'compareAtPrice': compareAtPrice,
43 | 'isAvailable': isAvailable,
44 | 'selectedOptions': selectedOptions,
45 | 'image': image,
46 | 'productImage': productImage,
47 | 'productId': productId
48 | };
49 | }
50 |
--------------------------------------------------------------------------------
/lib/model/shipping_rate.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'package:jvanila_flutter/jvanila.dart';
3 | import 'package:json_annotation/json_annotation.dart';
4 |
5 | part 'shipping_rate.g.dart';
6 |
7 | @JsonSerializable(nullable: false)
8 | class ShippingRate extends DataObject with _$ShippingRateSerializerMixin {
9 | String title;
10 | double price;
11 | String handle;
12 |
13 | ShippingRate({this.title, this.price, this.handle});
14 |
15 | factory ShippingRate.fromJson(Map json) => _$ShippingRateFromJson(json);
16 |
17 | @override
18 | String jsonify() {
19 | return new JsonEncoder().convert(toJson());
20 | }
21 |
22 | @override
23 | Map toMap([Map map]) {
24 | var map = new Map();
25 | map["title"] = title;
26 | map["price"] = price;
27 | map["handle"] = handle;
28 | return map;
29 | }
30 |
31 | @override
32 | int get hashCode => getHashCode();
33 |
34 | int getHashCode() {
35 | int result = title.hashCode;
36 |
37 | result = 31 * result + price.hashCode;
38 | result = 31 * result + handle.hashCode;
39 | return result;
40 | }
41 |
42 | @override
43 | bool operator ==(object) {
44 |
45 | if (this == object) {
46 | return true;
47 | }
48 | if (object == null || toString() != object.toString()) {
49 | return false;
50 | }
51 |
52 | ShippingRate shippingRate = object;
53 |
54 | if (title != shippingRate.title) return false;
55 | if (price != shippingRate.price) return false;
56 | if (handle != shippingRate.handle)
57 | return false;
58 |
59 | return true;
60 | }
61 |
62 | String toString() {
63 | return "ShippingRate{ " +
64 | " title ='" + title + '\'' +
65 | ", price ='" + price.toString() + '\'' +
66 | ", handle ='" + handle + '\'' +
67 | '}';
68 | }
69 | }
--------------------------------------------------------------------------------
/lib/model/shipping_rate.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'shipping_rate.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | ShippingRate _$ShippingRateFromJson(Map json) {
10 | return new ShippingRate(
11 | title: json['title'] as String,
12 | price: (json['price'] as num).toDouble(),
13 | handle: json['handle'] as String)
14 | ..crudOperation = json['crudOperation'] as String;
15 | }
16 |
17 | abstract class _$ShippingRateSerializerMixin {
18 | String get crudOperation;
19 | String get title;
20 | double get price;
21 | String get handle;
22 | Map toJson() => {
23 | 'crudOperation': crudOperation,
24 | 'title': title,
25 | 'price': price,
26 | 'handle': handle
27 | };
28 | }
29 |
--------------------------------------------------------------------------------
/lib/model/shop.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'shop.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Shop _$ShopFromJson(Map json) {
10 | return new Shop(
11 | name: json['name'] as String, description: json['description'] as String)
12 | ..crudOperation = json['crudOperation'] as String;
13 | }
14 |
15 | abstract class _$ShopSerializerMixin {
16 | String get crudOperation;
17 | String get name;
18 | String get description;
19 | Map toJson() => {
20 | 'crudOperation': crudOperation,
21 | 'name': name,
22 | 'description': description
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/lib/model/sort_type.dart:
--------------------------------------------------------------------------------
1 | //enum
2 |
3 | enum SortType {
4 | NAME,
5 | RECENT,
6 | RELEVANT,
7 | TYPE,
8 | PRICE_HIGH_TO_LOW,
9 | PRICE_LOW_TO_HIGH
10 | }
--------------------------------------------------------------------------------
/lib/model/state.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'state.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | State _$StateFromJson(Map json) {
10 | return new State(
11 | id: json['id'] as int,
12 | countryId: json['countryId'] as int,
13 | code: json['code'] as String,
14 | name: json['name'] as String)
15 | ..crudOperation = json['crudOperation'] as String;
16 | }
17 |
18 | abstract class _$StateSerializerMixin {
19 | String get crudOperation;
20 | int get id;
21 | int get countryId;
22 | String get code;
23 | String get name;
24 | Map toJson() => {
25 | 'crudOperation': crudOperation,
26 | 'id': id,
27 | 'countryId': countryId,
28 | 'code': code,
29 | 'name': name
30 | };
31 | }
32 |
--------------------------------------------------------------------------------
/lib/model/store.dart:
--------------------------------------------------------------------------------
1 | import 'package:jvanila_flutter/jvanila.dart';
2 |
3 | class Store extends DataObject {
4 | String storeId;
5 | String storeName;
6 | String storeAddress;
7 |
8 | Store({this.storeId, this.storeName, this.storeAddress});
9 | }
--------------------------------------------------------------------------------
/lib/model/variant_option.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'package:jvanila_flutter/jvanila.dart';
3 | import 'package:json_annotation/json_annotation.dart';
4 |
5 | part 'variant_option.g.dart';
6 |
7 | @JsonSerializable(nullable: false)
8 | class VariantOption extends DataObject with _$VariantOptionSerializerMixin {
9 | String name;
10 | String value;
11 |
12 | VariantOption({this.name, this.value});
13 |
14 | factory VariantOption.fromJson(Map json) => _$VariantOptionFromJson(json);
15 |
16 | @override
17 | String jsonify() {
18 | return new JsonEncoder().convert(toJson());
19 | }
20 |
21 | @override
22 | Map toMap([Map map]) {
23 | var map = new Map();
24 | map["name"] = name;
25 | map["value"] = value;
26 | return map;
27 | }
28 |
29 | @override
30 | int get hashCode => getHashCode();
31 |
32 | int getHashCode() {
33 | int result = name.hashCode;
34 |
35 | result = 31 * result + value.hashCode;
36 | return result;
37 | }
38 |
39 | @override
40 | bool operator ==(object) {
41 |
42 | if (this == object) {
43 | return true;
44 | }
45 | if (object == null || toString() != object.toString()) {
46 | return false;
47 | }
48 |
49 | VariantOption variantOption = object;
50 |
51 | if (name != variantOption.name) return false;
52 | if (value != variantOption.value) return false;
53 |
54 | return true;
55 | }
56 |
57 | String toString() {
58 | return "VariantOption{ " +
59 | " name ='" + name + '\'' +
60 | ", value ='" + value + '\'' +
61 | '}';
62 | }
63 | }
--------------------------------------------------------------------------------
/lib/model/variant_option.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'variant_option.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | VariantOption _$VariantOptionFromJson(Map json) {
10 | return new VariantOption(
11 | name: json['name'] as String, value: json['value'] as String)
12 | ..crudOperation = json['crudOperation'] as String;
13 | }
14 |
15 | abstract class _$VariantOptionSerializerMixin {
16 | String get crudOperation;
17 | String get name;
18 | String get value;
19 | Map toJson() => {
20 | 'crudOperation': crudOperation,
21 | 'name': name,
22 | 'value': value
23 | };
24 | }
25 |
--------------------------------------------------------------------------------
/lib/stopwatch.dart:
--------------------------------------------------------------------------------
1 | class StopWatch {
2 |
3 | int start;
4 |
5 | StopWatch() {
6 | start = new DateTime.now().millisecond;
7 | }
8 |
9 | String elapsedTime() {
10 | int now = new DateTime.now().millisecond;
11 | return "${now - start} ms";
12 | }
13 | }
--------------------------------------------------------------------------------
/shopify.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |