Skip to content

ygunayer/craftgate-java2elixir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

craftgate-java2elixir

Highly specific Java to Elixir converter that can be used to save time when syncing the ygunayer/craftgate-elixir-client codebase with craftgate/craftgate-java-client

How it Works

This project traverses the class hierarchy in craftgate-java-client, and for each data class and enumeration, it runs a conversion process and outputs them into the output/craftgate folder, with a sub path that matches the package path of the class, but converted into the Elixir conventions.

Enums make use of the Craftgate.Enum.__using__/1 macro:

Currency.java currency.ex
package io.craftgate.model;

public enum Currency {
    TRY,
    USD,
    EUR,
    GBP,
    ARS,
    BRL,
    CNY,
    AED,
    IQD
}
defmodule Craftgate.Model.Currency do
  use Craftgate.Enum, [
    :AED,
    :ARS,
    :EUR,
    :GBP,
    :USD,
    :TRY,
    :BRL,
    :IQD,
    :CNY
  ]
end

And data classes make use of the Craftgate.Serializable.__using__/1 macro:

FraudCheckParameters.java fraud_check_parameters.ex
package io.craftgate.request.dto;

import lombok.Data;

@Data
public class FraudCheckParameters {
    private String buyerExternalId;
    private String buyerPhoneNumber;
    private String buyerEmail;
}
defmodule Craftgate.Request.Dto.FraudCheckParameters do
  use Craftgate.Serializable, [
    buyer_external_id: :string,
    buyer_phone_number: :string,
    buyer_email: :string
  ]
end

Usage

  • Open up build.gradle and change the Craftgate Java client version to the version you would like to use
  • Run the Application class
  • Copy the contents of the output/craftgate folder into the lib/craftgate folder of the Craftgate Elixir client

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published