All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.fruitful.ecomerce.utils.MagentoInitService Maven / Gradle / Ivy

package io.fruitful.ecomerce.utils;

import io.fruitful.ecomerce.entities.MagentoSetting;
import io.fruitful.ecomerce.proxy.*;

import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
@Data
public class MagentoInitService {
	
	private MagentoCustomerApi magentoCustomerApi;
	
	//for admin and talent using integration token
	private MagentoProductApi magentoProductApi;
	
	//for customer using customer token.
	private MagentoProductApi magentoCustomerProductApi;
	private MagentoWishlistApi magentoWishlistApi;
	private MagentoCartApi magentoCartApi;
	private MagentoSetting magentoSetting;
	private String endpoint;
	private List defaultCategories;
	private Long defaultCategoryId;
	private Long talentsCategoryId;

	public void init(MagentoSetting magentoSetting) {
		String integrationToken = magentoSetting.getIntegrationToken();
		endpoint = magentoSetting.getEndpoint();
		magentoCustomerApi = RetrofitService.createService(MagentoCustomerApi.class, new MagentoInterceptor(integrationToken), endpoint);
		magentoProductApi = RetrofitService.createService(MagentoProductApi.class, new MagentoInterceptor(integrationToken), endpoint);
		magentoCustomerProductApi = RetrofitService.createService(MagentoProductApi.class, null, endpoint);
		magentoWishlistApi = RetrofitService.createService(MagentoWishlistApi.class, null, endpoint);
		magentoCartApi = RetrofitService.createService(MagentoCartApi.class, null, endpoint);
		defaultCategories = magentoSetting.getDefaultCategories();
		defaultCategoryId = magentoSetting.getDefaultCategoryId();
		talentsCategoryId = magentoSetting.getTalentsCategoryId();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy