Android Open Source - meets-android Mage Meets Address






From Project

Back to project page meets-android.

License

The source code is released under:

MIT License

If you think the Android project meets-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.theagilemonkeys.meets.magento.models;
//from w  w  w  .  j  av a 2s .  c o m
import com.google.api.client.util.Key;
import com.theagilemonkeys.meets.ApiMethodModelHelper;
import com.theagilemonkeys.meets.magento.methods.CustomerAddressDelete;
import com.theagilemonkeys.meets.magento.methods.CustomerAddressInfo;
import com.theagilemonkeys.meets.magento.methods.CustomerAddressUpdate;
import com.theagilemonkeys.meets.magento.models.base.MageMeetsModel;
import com.theagilemonkeys.meets.models.MeetsAddress;

import java.util.HashMap;
import java.util.Map;

import static com.theagilemonkeys.meets.utils.StringUtils.safeValueOf;

/**
 * Android Meets SDK
 * Original work Copyright (c) 2014 [TheAgileMonkeys]
 *
 * @author ??lvaro Lpez Espinosa
 */
public class MageMeetsAddress extends MageMeetsModel<MeetsAddress> implements MeetsAddress {
    final static public String MODE_BILLING = "billing";
    final static public String MODE_SHIPPING = "shipping";

    @Key private Integer customer_address_id;
    @Key private String address_id; // The same as customer_address_id.
    @Key private String mode;
    @Key private String firstname;
    @Key private String middlename;
    @Key private String lastname;
    @Key private String prefix;
    @Key private String suffix;
    @Key private String email;
    @Key private String company;
    @Key private Object street; //Something really weird happens when use String as type field. The server does not recognizes  it
    @Key private String city;
    @Key private int region_id;
    @Key private String region;
    @Key private String postcode;
    @Key private String country_id;
    @Key private String telephone;
    @Key private String fax;
    @Key private boolean is_default_billing;
    @Key private boolean is_default_shipping;

    //This is specific of magento
    public MeetsAddress setMode(String mode) {
        this.mode = mode;
        return this;
    }

    @Override
    public MeetsAddress fetch() {
        ApiMethodModelHelper.DelayedParams params = new ApiMethodModelHelper.DelayedParams() {
            @Override
            public Map<String, Object> buildParams() {
                Map<String, Object> params = new HashMap<String, Object>();
                params.put("addressId", getId());
                return params;
            }
        };


        pushMethod(new CustomerAddressInfo(), params).always(updateAndTrigger);
        return this;
    }

    @Override
    public MeetsAddress setId(int id) {
        customer_address_id = id;
        address_id = String.valueOf(id);
        return this;
    }

    @Override
    public int getId() {
        return customer_address_id > 0 ? customer_address_id : Integer.parseInt(address_id);
    }

    @Override
    public MeetsAddress setFirstName(String firstname) {
        this.firstname = firstname;
        return this;
    }

    @Override
    public MeetsAddress setLastName(String lastname) {
        this.lastname = lastname;
        return this;
    }

    @Override
    public MeetsAddress setCompany(String company) {
        this.company = company;
        return this;
    }

    @Override
    public MeetsAddress setStreet(String street) {
        this.street = street;
        return this;
    }

    @Override
    public MeetsAddress setCity(String city) {
        this.city = city;
        return this;
    }

    @Override
    public MeetsAddress setRegionId(int regionId) {
        this.region_id = regionId;
        return this;
    }

    @Override
    public MeetsAddress setRegion(String region) {
        this.region = region;
        return this;
    }

    @Override
    public MeetsAddress setPostCode(String postcode) {
        this.postcode = postcode;
        return this;
    }

    @Override
    public MeetsAddress setCountryId(String countryId) {
        country_id = countryId;
        return this;
    }

    @Override
    public MeetsAddress setTelephone(String telephone) {
        this.telephone = telephone;
        return this;
    }

    @Override
    public MeetsAddress setFax(String fax) {
        this.fax = fax;
        return this;
    }

    @Override
    public MeetsAddress setDefaultBilling(boolean defaultBilling) {
//        is_default_billing = defaultBilling ? 1 : 0;
        is_default_billing = defaultBilling;
        return this;
    }

    @Override
    public MeetsAddress setDefaultShipping(boolean defaultShipping) {
//        is_default_shipping = defaultShipping ? 1 : 0;
        is_default_shipping = defaultShipping;
        return this;
    }

    @Override
    public MeetsAddress save() {
        ApiMethodModelHelper.DelayedParams params = new ApiMethodModelHelper.DelayedParams() {
            @Override
            public Map<String, Object> buildParams() {
                Map<String, Object> params = new HashMap<String, Object>();
                params.put("addressId", getId());
                params.put("addressData", MageMeetsAddress.this);
                return params;
            }
        };

        forceNextCacheToBe(false);
        pushMethod(new CustomerAddressUpdate(), params).always(onlyTrigger);
        return this;
    }

    @Override
    public MeetsAddress remove() {
        ApiMethodModelHelper.DelayedParams params = new ApiMethodModelHelper.DelayedParams() {
            @Override
            public Map<String, Object> buildParams() {
                Map<String, Object> params = new HashMap<String, Object>();
                params.put("addressId", getId());
                return params;
            }
        };

        forceNextCacheToBe(false);
        pushMethod(new CustomerAddressDelete(), params).always(onlyTrigger);
        return this;
    }

    @Override
    public String getFirstName() {
        return firstname;
    }

    @Override
    public String getLastName() {
        return lastname;
    }

    @Override
    public String getCompany() {
        return company;
    }

    @Override
    public String getStreet() {
        return (String) street;
    }

    @Override
    public String getCity() {
        return city;
    }

    @Override
    public int getRegionId() {
        return region_id;
    }

    @Override
    public String getRegion() {
        return region;
    }

    @Override
    public String getPostCode() {
        return postcode;
    }

    @Override
    public String getCountryId() {
        return country_id;
    }

    @Override
    public String getTelephone() {
        return telephone;
    }

    @Override
    public String getFax() {
        return fax;
    }

    @Override
    public boolean isDefaultBilling() {
        return is_default_billing;
    }

    @Override
    public boolean isDefaultShipping() {
        return is_default_shipping;
    }

    @Override
    public String toString() {
        String res = safeValueOf(getFirstName()) + ' ' + safeValueOf(getLastName()) + '\n' +
                     safeValueOf(getStreet()) + '\n' +
                     safeValueOf(getCity()) + ", " + safeValueOf(getRegion()) + ", " + safeValueOf(getPostCode()) + '\n' +
                     safeValueOf(getCountryId()) + '\n' +
                     safeValueOf(getTelephone());
        return res;
    }
}




Java Source Code List

com.theagilemonkeys.meets.ApiMethodModelHelperInterface.java
com.theagilemonkeys.meets.ApiMethodModelHelper.java
com.theagilemonkeys.meets.ApiMethod.java
com.theagilemonkeys.meets.MeetsSpiceService.java
com.theagilemonkeys.meets.Meets.java
com.theagilemonkeys.meets.magento.RestApiMethod.java
com.theagilemonkeys.meets.magento.SoapApiMethod.java
com.theagilemonkeys.meets.magento.methods.CatalogCategoryInfo.java
com.theagilemonkeys.meets.magento.methods.CatalogCategoryLevel.java
com.theagilemonkeys.meets.magento.methods.CatalogCategoryTree.java
com.theagilemonkeys.meets.magento.methods.CatalogInventoryStockItemList.java
com.theagilemonkeys.meets.magento.methods.CatalogProductAttributeOptions.java
com.theagilemonkeys.meets.magento.methods.CatalogProductInfo.java
com.theagilemonkeys.meets.magento.methods.CatalogProductList.java
com.theagilemonkeys.meets.magento.methods.CustomerAddressCreate.java
com.theagilemonkeys.meets.magento.methods.CustomerAddressDelete.java
com.theagilemonkeys.meets.magento.methods.CustomerAddressInfo.java
com.theagilemonkeys.meets.magento.methods.CustomerAddressList.java
com.theagilemonkeys.meets.magento.methods.CustomerAddressUpdate.java
com.theagilemonkeys.meets.magento.methods.CustomerCustomerCreate.java
com.theagilemonkeys.meets.magento.methods.CustomerCustomerInfo.java
com.theagilemonkeys.meets.magento.methods.CustomerCustomerList.java
com.theagilemonkeys.meets.magento.methods.CustomerCustomerUpdate.java
com.theagilemonkeys.meets.magento.methods.Products.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartCreate.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartCustomerAddresses.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartCustomerSet.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartInfo.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartOrder.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartPaymentList.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartPaymentMethod.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartProductAdd.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartProductRemove.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartShippingList.java
com.theagilemonkeys.meets.magento.methods.ShoppingCartShippingMethod.java
com.theagilemonkeys.meets.magento.models.MageMeetsAddress.java
com.theagilemonkeys.meets.magento.models.MageMeetsCartItem.java
com.theagilemonkeys.meets.magento.models.MageMeetsCartPayment.java
com.theagilemonkeys.meets.magento.models.MageMeetsCartShipping.java
com.theagilemonkeys.meets.magento.models.MageMeetsCart.java
com.theagilemonkeys.meets.magento.models.MageMeetsCategory.java
com.theagilemonkeys.meets.magento.models.MageMeetsCustomer.java
com.theagilemonkeys.meets.magento.models.MageMeetsProduct.java
com.theagilemonkeys.meets.magento.models.MageStockInfoList.java
com.theagilemonkeys.meets.magento.models.MageStockItem.java
com.theagilemonkeys.meets.magento.models.base.MageMeetsCollectionPojos.java
com.theagilemonkeys.meets.magento.models.base.MageMeetsCollection.java
com.theagilemonkeys.meets.magento.models.base.MageMeetsFactory.java
com.theagilemonkeys.meets.magento.models.base.MageMeetsModel.java
com.theagilemonkeys.meets.models.MeetsAddress.java
com.theagilemonkeys.meets.models.MeetsCart.java
com.theagilemonkeys.meets.models.MeetsCategory.java
com.theagilemonkeys.meets.models.MeetsCustomer.java
com.theagilemonkeys.meets.models.MeetsProduct.java
com.theagilemonkeys.meets.models.MeetsStock.java
com.theagilemonkeys.meets.models.base.MeetsCollectionPojos.java
com.theagilemonkeys.meets.models.base.MeetsCollection.java
com.theagilemonkeys.meets.models.base.MeetsFactory.java
com.theagilemonkeys.meets.models.base.MeetsListener.java
com.theagilemonkeys.meets.models.base.MeetsModel.java
com.theagilemonkeys.meets.utils.Copier.java
com.theagilemonkeys.meets.utils.StringUtils.java
com.theagilemonkeys.meets.utils.soap.Serializable.java
com.theagilemonkeys.meets.utils.soap.SoapParser.java