コード例 #1
0
        /// <summary>
        /// Initializes a <see ref="ShopifyClient">ShopifyClient </see> that can be used to query the Storefront API.
        /// The default client which can be accessed by calling <see ref="ShopifyBuy.Client">ShopifyBuy.Client() </see> which is
        /// initialized after <see ref="ShopifyBuy.Init">ShopifyBuy.Init </see> is called. To access the client for the specific
        /// domain passed, use <see ref="ShopifyBuy.Client">ShopifyBuy.Client(domain) </see>.
        /// </summary>
        /// <param name="accessToken">access token that was generated for your store</param>
        /// <param name="domain">domain of your Shopify store</param>
        /// \code
        /// // Example that initializes the Shopify SDK for Unity
        /// string accessToken = "b8d417759a62f7b342f3735dbe86b322";
        /// string shopDomain = "unity-buy-sdk.myshopify.com";
        ///
        /// // Init only needs to be called once
        /// ShopifyBuy.Init(accessToken, shopDomain);
        /// \endcode
        public static ShopifyClient Init(string accessToken, string domain)
        {
            if (!ClientByDomain.ContainsKey(domain))
            {
                ClientByDomain[domain] = new ShopifyClient(accessToken, domain);

                if (DefaultClient == null)
                {
                    DefaultClient = ClientByDomain[domain];
                }
            }

            return(ClientByDomain[domain]);
        }
コード例 #2
0
        /// <summary>
        /// Typically not used, but it is possible to create a <see ref="ShopifyClient">ShopifyClient </see> by passing an instance
        /// that implements <see ref="BaseLoader">BaseLoader </see>. <see ref="BaseLoader">BaseLoaders </see> handle network communicationication with
        /// the Storefront API. This functionality is useful if you'd like to use the Shopify SDK for Unity in a C# environment
        /// outside of Unity. The <c>domain</c> string used to access specific initialized clients is inferred from
        /// <see ref="BaseLoader">BaseLoader.Domain</see> which can be used to request a specific client.
        /// </summary>
        /// <param name="loader">a loader which will handle network communicationication with the Storefront API</param>
        /// \code
        /// // Mock example using a custom loader for another C# platform
        /// string accessToken = "b8d417759a62f7b342f3735dbe86b322";
        /// string shopDomain = "unity-buy-sdk.myshopify.com";
        ///
        /// CustomLoaderForNonUnityPlatform loader = new CustomLoaderForNonUnityPlatform(accessToken, shopDomain);
        ///
        /// // Init only needs to be called once
        /// ShopifyBuy.Init(loader);
        /// \endcode
        public static ShopifyClient Init(BaseLoader loader)
        {
            string domain = loader.Domain;

            if (!ClientByDomain.ContainsKey(domain))
            {
                ClientByDomain[domain] = new ShopifyClient(loader);

                if (DefaultClient == null)
                {
                    DefaultClient = ClientByDomain[domain];
                }
            }

            return(ClientByDomain[domain]);
        }
コード例 #3
0
ファイル: Cart.cs プロジェクト: bluemutedwisdom/unity-buy-sdk
        /// <summary>
        /// Constructs a new cart using a <see ref="ShopifyClient">ShopifyClient </see>. Typically, carts won't be
        /// instantiated directly, but will rather be instatiated using <see ref="ShopifyClient.Cart">ShopifyBuy.Client().Cart() </see>.
        /// </summary>
        /// <param name="client">client associated with this cart</param>
        /// \code
        /// // Example that creates a cart using a ShopifyClient and checks how many line items it has
        /// // (spoiler: it has 0 line items since the cart was just created).
        /// ShopifyClient client = new ShopifyClient(accessToken, shopDomain);
        ///
        /// Cart cart = new Cart(client);
        ///
        /// Debug.Log(cart.LineItems.All().Count);
        /// \endcode
        public Cart(ShopifyClient client)
        {
            State  = new CartState(client);
            Client = client;

#if UNITY_EDITOR || UNITY_STANDALONE
            WebCheckout    = new UnityWebCheckout(this, client);
            NativeCheckout = null;
#elif UNITY_IOS
            WebCheckout    = new iOSWebCheckout(this, client);
            NativeCheckout = new iOSNativeCheckout(State);
#elif UNITY_ANDROID
            WebCheckout    = new AndroidWebCheckout(this, client);
            NativeCheckout = new AndroidNativeCheckout(State);
#else
            WebCheckout    = null;
            NativeCheckout = null;
#endif
        }
コード例 #4
0
ファイル: CartState.cs プロジェクト: nickarthur/unity-buy-sdk
 public CartState(ShopifyClient client)
 {
     Client               = client;
     _LineItems           = new CartLineItems();
     _LineItems.OnChange += OnLineItemChange;
 }