Skip to content

Commit

Permalink
v3.0.0011
Browse files Browse the repository at this point in the history
Added UpdateListingMethod
  • Loading branch information
cmunden committed Jun 13, 2023
1 parent 8eeea2b commit 2ecf6d0
Show file tree
Hide file tree
Showing 13 changed files with 566 additions and 57 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ out of the gate. There's nothing to change, unless you need a specific feature
implementations (ex. a different Http transport).

### Installation
Version 3.0.0010 of JEtsy is available from the Maven Central Repository [here](https://search.maven.org/search?q=g:com.notronix%20a:JEtsy)
Version 3.0.0011 of JEtsy is available from the Maven Central Repository [here](https://search.maven.org/search?q=g:com.notronix%20a:JEtsy)

<dependency>
<groupId>com.notronix</groupId>
<artifactId>JEtsy</artifactId>
<version>3.0.0010</version>
<version>3.0.0011</version>
</dependency>

### Usage (TODO: update to V3 implementation with OAuth2.0)
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
}

group 'com.notronix'
version '3.0.0010'
version '3.0.0011'

sourceCompatibility = 1.8

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,4 @@ public interface CreateDraftListingMethod<C> extends Method<Listing, C>

@EtsyParameter
void setType(ListingType type);

Predicate<Integer> QUANTITY_VALIDATOR = quantity -> (nonNull(quantity) && quantity > 0);
Predicate<Float> PRICE_VALIDATOR = price -> (nonNull(price) && price > 0.00);
Predicate<Long> TAXONOMY_ID_VALIDATOR = taxonomyId -> (nonNull(taxonomyId) && taxonomyId > 0);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
import com.notronix.etsy.api.Resource;
import com.notronix.etsy.api.authentication.model.AccessToken;

import java.util.function.Predicate;

import static java.util.Objects.nonNull;

public interface ListingResource<C> extends Resource
{
Predicate<Integer> QUANTITY_VALIDATOR = quantity -> (nonNull(quantity) && quantity > 0);
Predicate<Float> PRICE_VALIDATOR = price -> (nonNull(price) && price > 0.00);
Predicate<Long> TAXONOMY_ID_VALIDATOR = taxonomyId -> (nonNull(taxonomyId) && taxonomyId > 0);

CreateDraftListingMethod<C> createCreateDraftListingMethod(AccessToken accessToken);

GetListingInventoryMethod<C> createGetListingInventoryMethod(AccessToken accessToken);
Expand All @@ -22,4 +30,6 @@ public interface ListingResource<C> extends Resource
GetListingVariationImagesMethod<C> createGetListingVariationImagesMethod();

UpdateVariationImagesMethod<C> createUpdateVariationImagesMethod(AccessToken accessToken);

UpdateListingMethod<C> createUpdateListingMethod(AccessToken accessToken);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
package com.notronix.etsy.api.listings.method;

import com.notronix.etsy.api.common.method.EtsyParameter;
import com.notronix.etsy.api.common.method.Method;
import com.notronix.etsy.api.common.method.ParameterPosition;
import com.notronix.etsy.api.common.model.DimensionUnit;
import com.notronix.etsy.api.common.model.WeightUnit;
import com.notronix.etsy.api.listings.model.*;

import java.util.List;

public interface UpdateListingMethod<C> extends Method<Listing, C>
{
@EtsyParameter(nullable = false, position = ParameterPosition.PATH)
void setShopId(Long shopId);

@EtsyParameter(nullable = false, position = ParameterPosition.PATH)
void setListingId(Long listingId);

@EtsyParameter
void setImageIds(List<Long> imageIds);

@EtsyParameter
void setTitle(String title);

@EtsyParameter
void setDescription(String description);

@EtsyParameter
void setMaterials(List<String> materials);

@EtsyParameter
void setShouldAutoRenew(Boolean shouldAutoRenew);

@EtsyParameter
void setShippingProfileId(Long shippingProfileId);

@EtsyParameter
void setReturnPolicyId(Long returnPolicyId);

@EtsyParameter
void setShopSectionId(Long shopSectionId);

@EtsyParameter
void setWeight(Float itemWeight);

@EtsyParameter
void setLength(Float itemLength);

@EtsyParameter
void setWidth(Float itemWidth);

@EtsyParameter
void setHeight(Float itemHeight);

@EtsyParameter
void setWeightUnit(WeightUnit itemWeightUnit);

@EtsyParameter
void setDimensionUnit(DimensionUnit itemDimensionUnit);

@EtsyParameter
void setTaxable(Boolean taxable);

@EtsyParameter
void setTaxonomyId(Long taxonomyId);

@EtsyParameter
void setTags(List<String> tags);

@EtsyParameter
void setWhoMade(WhoMade whoMade);

@EtsyParameter
void setWhenMade(WhenMade whenMade);

@EtsyParameter
void setFeaturedRank(Integer featuredRank);

@EtsyParameter
void setPersonalizable(Boolean personalizable);

@EtsyParameter
void setPersonalizationRequired(Boolean personalizationRequired);

@EtsyParameter
void setMaxPersonalizationCharacterCount(Integer maxPersonalizationCharacterCount);

@EtsyParameter
void setPersonalizationInstructions(String personalizationInstructions);

@EtsyParameter
void setState(ListingState state);

@EtsyParameter
void setSupply(Boolean supply);

@EtsyParameter
void setProductionPartnerIds(List<Long> productionPartnerIds);

@EtsyParameter
void setType(ListingType type);
}
40 changes: 20 additions & 20 deletions src/main/java/com/notronix/etsy/impl/EtsyAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.gson.reflect.TypeToken;
import com.notronix.etsy.api.*;
import com.notronix.etsy.api.authentication.method.AuthResource;
import com.notronix.etsy.api.common.method.Method;
import com.notronix.etsy.api.common.method.OAuthMethod;
import com.notronix.etsy.api.listings.method.ListingResource;
import com.notronix.etsy.api.shops.method.ShopResource;
import com.notronix.etsy.api.taxonomy.method.TaxonomyResource;
import com.notronix.etsy.api.users.method.UserResource;
import com.notronix.etsy.impl.authentication.method.EtsyAuthResource;
import com.notronix.etsy.impl.listings.method.EtsyListingResource;
import com.notronix.etsy.impl.shops.method.EtsyShopResource;
import com.notronix.etsy.impl.taxonomy.method.EtsyTaxonomyResource;
import com.notronix.etsy.impl.users.method.EtsyUserResource;

import java.util.Collections;
import java.util.HashMap;
Expand All @@ -26,11 +26,11 @@ public class EtsyAPI implements API<HttpContent>
private HttpRequestFactory requestFactory;
private Marshaller marshaller;
private Unmarshaller unmarshaller;
private AuthResource<HttpContent> authResource;
private UserResource<HttpContent> userResource;
private ListingResource<HttpContent> listingResource;
private ShopResource<HttpContent> shopResource;
private TaxonomyResource<HttpContent> taxonomyResource;
private EtsyAuthResource authResource;
private EtsyUserResource userResource;
private EtsyListingResource listingResource;
private EtsyShopResource shopResource;
private EtsyTaxonomyResource taxonomyResource;

public Marshaller getMarshaller() {
return marshaller;
Expand All @@ -51,47 +51,47 @@ public void setUnmarshaller(Unmarshaller unmarshaller) {
}

@Override
public AuthResource<HttpContent> getAuthResource() {
public EtsyAuthResource getAuthResource() {
return authResource;
}

public void setAuthResource(AuthResource<HttpContent> authResource) {
public void setAuthResource(EtsyAuthResource authResource) {
this.authResource = authResource;
}

@Override
public UserResource<HttpContent> getUserResource() {
public EtsyUserResource getUserResource() {
return userResource;
}

public void setUserResource(UserResource<HttpContent> userResource) {
public void setUserResource(EtsyUserResource userResource) {
this.userResource = userResource;
}

@Override
public ListingResource<HttpContent> getListingResource() {
public EtsyListingResource getListingResource() {
return listingResource;
}

public void setListingResource(ListingResource<HttpContent> listingResource) {
public void setListingResource(EtsyListingResource listingResource) {
this.listingResource = listingResource;
}

@Override
public ShopResource<HttpContent> getShopResource() {
public EtsyShopResource getShopResource() {
return shopResource;
}

public void setShopResource(ShopResource<HttpContent> shopResource) {
public void setShopResource(EtsyShopResource shopResource) {
this.shopResource = shopResource;
}

@Override
public TaxonomyResource<HttpContent> getTaxonomyResource() {
public EtsyTaxonomyResource getTaxonomyResource() {
return taxonomyResource;
}

public void setTaxonomyResource(TaxonomyResource<HttpContent> taxonomyResource) {
public void setTaxonomyResource(EtsyTaxonomyResource taxonomyResource) {
this.taxonomyResource = taxonomyResource;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@
public class EtsyAuthResource implements AuthResource<HttpContent>
{
@Override
public PingMethod<HttpContent> createPingMethod() {
public EtsyPingMethod createPingMethod() {
return new EtsyPingMethod();
}

@Override
public RefreshTokenMethod<HttpContent> createRefreshTokenMethod(AppKey appKey, RefreshToken refreshToken) {
public EtsyRefreshTokenMethod createRefreshTokenMethod(AppKey appKey, RefreshToken refreshToken) {
return new EtsyRefreshTokenMethod().withAppKey(appKey).withRefreshToken(refreshToken);
}

@Override
public ExchangeTokenMethod<HttpContent> createExchangeTokenMethod(AppKey appKey, LegacyToken legacyToken) {
public EtsyExchangeTokenMethod createExchangeTokenMethod(AppKey appKey, LegacyToken legacyToken) {
return new EtsyExchangeTokenMethod().withAppKey(appKey).withLegacyToken(legacyToken);
}

@Override
public TokenScopesMethod<HttpContent> createTokenScopesMethod(AccessToken accessToken) {
public EtsyTokenScopesMethod createTokenScopesMethod(AccessToken accessToken) {
return new EtsyTokenScopesMethod().withToken(accessToken);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

import static com.notronix.albacore.ContainerUtils.thereAreNo;
import static com.notronix.etsy.api.MethodUtils.putIfProvided;
import static com.notronix.etsy.api.listings.method.ListingResource.*;
import static java.util.Objects.requireNonNull;

public class EtsyCreateDraftListingMethod extends AbstractEtsyMethod<Listing>

Check warning on line 30 in src/main/java/com/notronix/etsy/impl/listings/method/EtsyCreateDraftListingMethod.java

View workflow job for this annotation

GitHub Actions / qodana

Overly complex class

Overly complex class `EtsyCreateDraftListingMethod` (cyclomatic complexity = 114)
Expand Down Expand Up @@ -104,8 +105,8 @@ public HttpContent buildRequestContent(Marshaller marshaller) {
putIfProvided(params, "item_length", length);
putIfProvided(params, "item_width", width);
putIfProvided(params, "item_height", height);
putIfProvided(params, "item_weight_unit", weightUnit.toString());
putIfProvided(params, "item_dimensions_unit", dimensionUnit.toString());
putIfProvided(params, "item_weight_unit", weightUnit == null ? null : weightUnit.name());
putIfProvided(params, "item_dimensions_unit", dimensionUnit == null ? null : dimensionUnit.name());
putIfProvided(params, "is_personalizable", personalizable);
putIfProvided(params, "personalization_is_required", personalizationRequired);
putIfProvided(params, "personalization_char_count_max", maxPersonalizationCharacterCount);
Expand All @@ -118,7 +119,7 @@ public HttpContent buildRequestContent(Marshaller marshaller) {
putIfProvided(params, "is_customizable", customizable);
putIfProvided(params, "should_auto_renew", shouldAutoRenew);
putIfProvided(params, "is_taxable", taxable);
putIfProvided(params, "type", type.toString());
putIfProvided(params, "type", type == null ? null : type.name());

return new UrlEncodedContent(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,52 @@
public class EtsyListingResource implements ListingResource<HttpContent>
{
@Override
public CreateDraftListingMethod<HttpContent> createCreateDraftListingMethod(AccessToken accessToken) {
public EtsyCreateDraftListingMethod createCreateDraftListingMethod(AccessToken accessToken) {
return new EtsyCreateDraftListingMethod().withAccessToken(accessToken);
}

@Override
public GetListingInventoryMethod<HttpContent> createGetListingInventoryMethod(AccessToken accessToken) {
public EtsyGetListingInventoryMethod createGetListingInventoryMethod(AccessToken accessToken) {
return new EtsyGetListingInventoryMethod().withAccessToken(accessToken);
}

@Override
public GetListingsByShopMethod<HttpContent> createGetListingsByShopMethod(AccessToken accessToken) {
public EtsyGetListingsByShopMethod createGetListingsByShopMethod(AccessToken accessToken) {
return new EtsyGetListingsByShopMethod().withAccessToken(accessToken);
}

@Override
public GetListingMethod<HttpContent> createGetListingMethod() {
public EtsyGetListingMethod createGetListingMethod() {
return new EtsyGetListingMethod();
}

@Override
public UpdateListingInventoryMethod<HttpContent> createUpdateListingInventoryMethod(AccessToken accessToken) {
public EtsyUpdateListingInventoryMethod createUpdateListingInventoryMethod(AccessToken accessToken) {
return new EtsyUpdateListingInventoryMethod().withAccessToken(accessToken);
}

@Override
public UploadListingImageMethod<HttpContent> createUploadListingImageMethod(AccessToken accessToken) {
public EtsyUploadListingImageMethod createUploadListingImageMethod(AccessToken accessToken) {
return new EtsyUploadListingImageMethod().withAccessToken(accessToken);
}

@Override
public GetListingImageMethod<HttpContent> createGetListingImageMethod() {
public EtsyGetListingImageMethod createGetListingImageMethod() {
return new EtsyGetListingImageMethod();
}

@Override
public GetListingVariationImagesMethod<HttpContent> createGetListingVariationImagesMethod() {
public EtsyGetListingVariationImagesMethod createGetListingVariationImagesMethod() {
return new EtsyGetListingVariationImagesMethod();
}

@Override
public UpdateVariationImagesMethod<HttpContent> createUpdateVariationImagesMethod(AccessToken accessToken) {
public EtsyUpdateVariationImagesMethod createUpdateVariationImagesMethod(AccessToken accessToken) {
return new EtsyUpdateVariationImagesMethod().withAccessToken(accessToken);
}

@Override
public UpdateListingMethod<HttpContent> createUpdateListingMethod(AccessToken accessToken) {
return new EtsyUpdateListingMethod().withAccessToken(accessToken);
}
}
Loading

0 comments on commit 2ecf6d0

Please sign in to comment.