Skip to content

mareklat/allegro-nice-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

allegro-nice-api

Flexible and easy to use java api for allegro service focused on trading operation on allegro platform.

Requirements

Install

git clone https://github.com/awronski/allegro-nice-api.git
cd allegro-nice-api
mvn package install

Tests are skipped by default during packaging because of bugs in allegro test environment. If you want to run the test you have to rename test-credentions.template to test-credentions.properties and set the credentials. Than run the tests:

mvn compile test -P testprof

Usage

Initialize object

int countryId = 1;
Configuration conf = new Configuration(countryId);
Credentials cred = new Credentials("username", "password", "key");

IAllegroNiceApi allegro = AllegroNiceApi.Builder()
        .conf(conf)
        .cred(cred)
        .build();

Login

allegro.login();

Get user's auctions

Observable<Auction> auctions = api.getAuctions();

Get list of deals

long startingPoint = 0;
Observable<Deal> deals =  api.getDeals(startingPoint);

Get list of payments with clients data

Observable<Payment> payments - getPayments(deals);

Subscribe to journal

You can subscribe to user's journal using api.getSiteJournal(startingPoint). Like above methods this one returns Observable object too.

long startingPoint = 0;
api.getSiteJournal(startingPoint)
    .subscribe(
        j -> System.out.println("on next: " + j),
        t -> System.out.println("on error: " + t),
        () -> System.out.println("on complete")
    );

Read more about RxJava.

Create new auction

To create new auction you need to create list of auctions fields. Id of the field is the same as on the allegro service. Check getSellFormFields(categoryId) to get all possible fields for a given category.

List<NewAuctionField> fields = new ArrayList<>();
fields.add( new NewAuctionField(1, FieldType.Type.STRING, "Auction title") );
[...]
CreatedAuction created = api.createNewAuction(fields);

Change auction's quantity

ChangedQty changedQty = api.changeQty(itemId, 5);

Finish auctions

List<FinishAuctionFailure> failures = api.finishAuctions(List<Long> itemsIds);

Get and create feedbacks

int counter = api.getWaintingFeedbackCounter();
Observable<WaitingFeedback> api.getWaitingFeedbacks();

List<CreateFeedback> create = new ArrayList<>(..)
List<CreatedFeedback> =  api.createFeedbacks(create)

Get system messages

List<AllegroMessage> msgs = allegro.getAllMessages(LocalDateTime.now().minusDays(30));

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Flexible and easy to use java api for allegro service.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%