Added settings and webhooks api

This commit is contained in:
Gilbert Kimutai 2019-04-07 09:15:04 +03:00
parent 53b865824f
commit cf671d332e
10 changed files with 426 additions and 180 deletions

View File

@ -0,0 +1,34 @@
package me.gilo.wc.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import me.gilo.wc.R;
import me.gilo.wc.adapter.viewholder.ProductViewHolder;
import me.gilo.woodroid.models.Product;
import java.util.List;
public class ListAdapter extends RecyclerView.Adapter<ProductViewHolder> {
private List<Product> products;
public ListAdapter(List<Product> products) {
this.products = products;
}
@Override
public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
return new ProductViewHolder(parent.getContext(), LayoutInflater.from(parent.getContext()).inflate(R.layout.single_product_item, parent, false));
}
@Override
public void onBindViewHolder(ProductViewHolder holder, int position) {
holder.renderView(products.get(position));
}
@Override
public int getItemCount() {
return products.size() == 0 ? 0 : products.size();
}
}

View File

@ -244,6 +244,6 @@
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

View File

@ -8,7 +8,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0-alpha08'
classpath 'com.android.tools.build:gradle:3.5.0-alpha10'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.gms:google-services:4.0.1'
// NOTE: Do not place your application dependencies here; they belong

View File

@ -1,176 +0,0 @@
package me.gilo.woodroid.data.api;
import me.gilo.woodroid.data.callbacks.*;
import me.gilo.woodroid.data.callbacks.Data;
import me.gilo.woodroid.models.*;
import retrofit2.Call;
import retrofit2.http.*;
import rx.Observable;
import java.util.ArrayList;
import java.util.Map;
public interface API {
@GET
Observable<StoreCallback> store(@Url String url);
////////////////////////////////////////////////////////////////////////
//products
////////////////////////////////////////////////////////////////////////
@GET("products/categories")
Call<ArrayList<Category>> getCategories();
@GET
Call<CategoriesCallback> getCategories2(@Url String url);
@GET("products")
Call<ArrayList<Product>> getProducts();
@GET("products")
Call<ArrayList<Product>> getProducts(@Query("filter[category]") String category);
@GET("products")
Call<ArrayList<Product>> search(@Query("search") String search);
@GET
Call<ReviewsCallback> getProductReviews(@Url String url);
@GET("products")
Call<ArrayList<Product>> filter(@QueryMap Map<String, String> filter);
@GET("products/{id}")
Call<ProductCallback> getRelatedProducts(@Path("id") int id);
@GET("products/{id}")
Call<Product> getProduct(@Path("id") int id);
////////////////////////////////////////////////////////////////////////
//orders
////////////////////////////////////////////////////////////////////////
@GET("orders")
Observable<OrderCallback> getOrders();
@Headers("Content-Type: application/json")
@POST("orders")
Call<OrderData> createOrder(@Body OrderData order);
////////////////////////////////////////////////////////////////////////
//customer
////////////////////////////////////////////////////////////////////////
@GET
Observable<OrderCallback> viewMyOrders(@Url String url);
@Headers("Content-Type: application/json")
@POST("customers")
Call<CustomerData> registerUser(@Body CustomerData body);
@Headers("Content-Type: application/json")
@POST("customers")
Call<Data> registerUser2(@Body Data body);
@GET
Call<Customer> loginUser(@Url String url);
@GET("customers/email/{email}")
Call<Data> loginUser2(@Path("email") String email);
////////////////////////////////////////////////////////////////////////
/** Coupons
The coupons API allows you to
1. create,
2. view,
3. update
4. delete
individual, or a batch, of coupon codes.
**/
////////////////////////////////////////////////////////////////////////
@Headers("Content-Type: application/json")
@POST("coupons")
Call<Coupon> createCoupon(@Body Coupon body);
@GET("coupons/{id}")
Call<Coupon> viewCoupon(@Path("id") int id);
@GET("coupons/count")
Call<Integer> viewCouponCount();
@GET("coupons")
Observable<Coupon> viewCouponList(@Path("id") int id);
@PUT("coupons/{id}")
Call<Coupon> updateCoupon(@Path("id") int id);
@DELETE("coupons/{id}")
Call<String> deleteCoupon(@Path("id") int id);
///////////////////////////////////////////////////////////////////////
//Cart
////////////////////////////////////////////////////////////////////////
/*
/coupons
/coupons/count
/coupons/<id>
/coupons/code/<code>
/coupons/bulk
/customers
/customers/count
/customers/<id>
/customers/email/<email>
/customers/<id>/orders
/customers/<id>/downloads
/customers/bulk
/orders
/orders/count
/orders/statuses
/orders/<id>
/orders/<order_id>/notes
/orders/<order_id>/notes/<id>
/orders/<order_id>/refunds
/orders/<order_id>/refunds/<id>
/orders/bulk
/products
/products/count
/products/<id>
/products/<id>/reviews
/products/<id>/orders
/products/categories
/products/categories/<id>
/products/tags
/products/tags/<id>
/products/shipping_classes
/products/shipping_classes/<id>
/products/attributes
/products/attributes/<id>
/products/attributes/<attribute_id>/terms
/products/attributes/<attribute_id>/terms/<id>
/products/bulk
/reports
/reports/sales
/reports/sales/top_sellers
/taxes
/taxes/count
/taxes/<id>
/taxes/classes
/taxes/classes/count
/taxes/classes/<slug>
/taxes/bulk
/webhooks
/webhooks/count
/webhooks/<id>
/webhooks/<webhook_id>/deliveries
/webhooks/<webhook_id>/deliveries/<id>
*/
}

View File

@ -2,7 +2,9 @@ package me.gilo.woodroid.data.api;
import me.gilo.woodroid.models.SettingGroup;
import me.gilo.woodroid.models.SettingOption;
import me.gilo.woodroid.models.TaxRate;
import me.gilo.woodroid.models.WebhookDelivery;
import retrofit2.Call;
import retrofit2.http.*;
@ -15,6 +17,15 @@ public interface SettingsAPI {
@GET("settings")
Call<List<SettingGroup>> settings();
@GET("settings/{group_id}/{id}")
Call<SettingOption> option(@Path("group_id") int group_id, @Path("id") int option_id);
@GET("settings/{id}")
Call<List<SettingOption>> options(@Path("id") int group_id);
@Headers("Content-Type: application/json")
@GET("settings/{group_id}/{id}")
Call<SettingOption> update(@Path("group_id") int group_id, @Path("id") int option_id);

View File

@ -0,0 +1,43 @@
package me.gilo.woodroid.data.api;
import me.gilo.woodroid.models.*;
import retrofit2.Call;
import retrofit2.http.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public interface WebhookAPI {
@Headers("Content-Type: application/json")
@POST("webhooks")
Call<Webhook> create(@Body Webhook body);
@GET("webhooks")
Call<List<Webhook>> list();
@GET("webhooks/{id}")
Call<Webhook> view(@Path("id") int id);
@GET("webhooks/{id}/deliveries/{delivery_id}")
Call<WebhookDelivery> delivery(@Path("id") int webhook_id, @Path("delivery_id") int delivery_id);
@GET("webhooks/{id}/deliveries")
Call<List<WebhookDelivery>> deliveries(@Path("id") int webhook_id);
@Headers("Content-Type: application/json")
@PUT("webhooks/{id}")
Call<Webhook> update(@Path("id") int id, @Body Webhook body);
@DELETE("webhooks/{id}")
Call<Webhook> delete(@Path("id") int id);
@DELETE("webhooks/{id}")
Call<Webhook> delete(@Path("id") int id, @Query("force") boolean force);
@GET("webhooks")
Call<ArrayList<Webhook>> filter(@QueryMap Map<String, String> filter);
}

View File

@ -2,10 +2,12 @@ package me.gilo.woodroid.models;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Map;
public class SettingOption {
String id;
String option;
String label;
String description;
String value;
@ -14,8 +16,86 @@ public class SettingOption {
String tip;
String placeholder;
String type;
String options;
Map<String, String> options;
String group_id;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getDefault_value() {
return default_value;
}
public void setDefault_value(String default_value) {
this.default_value = default_value;
}
public String getTip() {
return tip;
}
public void setTip(String tip) {
this.tip = tip;
}
public String getPlaceholder() {
return placeholder;
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Map<String, String> getOptions() {
return options;
}
public void setOptions(Map<String, String> options) {
this.options = options;
}
public String getGroup_id() {
return group_id;
}
public void setGroup_id(String group_id) {
this.group_id = group_id;
}
}

View File

@ -0,0 +1,123 @@
package me.gilo.woodroid.models;
import java.util.Date;
public class Webhook {
int id;
String name;
String status;
String topic;
String resource;
String event;
String[] hooks;
String delivery_url;
String secret;
Date date_created;
Date date_created_gmt;
Date date_modified;
Date date_modified_gmt;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getTopic() {
return topic;
}
public void setTopic(String topic) {
this.topic = topic;
}
public String getResource() {
return resource;
}
public void setResource(String resource) {
this.resource = resource;
}
public String getEvent() {
return event;
}
public void setEvent(String event) {
this.event = event;
}
public String[] getHooks() {
return hooks;
}
public void setHooks(String[] hooks) {
this.hooks = hooks;
}
public String getDelivery_url() {
return delivery_url;
}
public void setDelivery_url(String delivery_url) {
this.delivery_url = delivery_url;
}
public String getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = secret;
}
public Date getDate_created() {
return date_created;
}
public void setDate_created(Date date_created) {
this.date_created = date_created;
}
public Date getDate_created_gmt() {
return date_created_gmt;
}
public void setDate_created_gmt(Date date_created_gmt) {
this.date_created_gmt = date_created_gmt;
}
public Date getDate_modified() {
return date_modified;
}
public void setDate_modified(Date date_modified) {
this.date_modified = date_modified;
}
public Date getDate_modified_gmt() {
return date_modified_gmt;
}
public void setDate_modified_gmt(Date date_modified_gmt) {
this.date_modified_gmt = date_modified_gmt;
}
}

View File

@ -0,0 +1,116 @@
package me.gilo.woodroid.models;
import java.util.Date;
import java.util.Map;
public class WebhookDelivery {
int id;
String duration;
String summary;
String request_url;
Map<String, String> request_headers;
String request_body;
String response_code;
String response_message;
Map<String, String> response_headers;
String response_body;
Date date_created;
Date date_created_gmt;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDuration() {
return duration;
}
public void setDuration(String duration) {
this.duration = duration;
}
public String getSummary() {
return summary;
}
public void setSummary(String summary) {
this.summary = summary;
}
public String getRequest_url() {
return request_url;
}
public void setRequest_url(String request_url) {
this.request_url = request_url;
}
public Map<String, String> getRequest_headers() {
return request_headers;
}
public void setRequest_headers(Map<String, String> request_headers) {
this.request_headers = request_headers;
}
public String getRequest_body() {
return request_body;
}
public void setRequest_body(String request_body) {
this.request_body = request_body;
}
public String getResponse_code() {
return response_code;
}
public void setResponse_code(String response_code) {
this.response_code = response_code;
}
public String getResponse_message() {
return response_message;
}
public void setResponse_message(String response_message) {
this.response_message = response_message;
}
public Map<String, String> getResponse_headers() {
return response_headers;
}
public void setResponse_headers(Map<String, String> response_headers) {
this.response_headers = response_headers;
}
public String getResponse_body() {
return response_body;
}
public void setResponse_body(String response_body) {
this.response_body = response_body;
}
public Date getDate_created() {
return date_created;
}
public void setDate_created(Date date_created) {
this.date_created = date_created;
}
public Date getDate_created_gmt() {
return date_created_gmt;
}
public void setDate_created_gmt(Date date_created_gmt) {
this.date_created_gmt = date_created_gmt;
}
}

View File

@ -0,0 +1,15 @@
package me.gilo.woodroid.models.filters;
public class WebhookFilter extends ListFilter{
String status;
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
addFilter("status", status);
}
}