Initial commit

This commit is contained in:
malkoas 2022-01-27 14:21:17 +03:00
commit 57f84d6897
14 changed files with 769 additions and 0 deletions

29
.github/workflows/build.yml vendored Normal file
View File

@ -0,0 +1,29 @@
name: Build Artifact
on:
pull_request:
branches:
- '*'
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: Install thrift
uses: valitydev/action-setup-thrift@v0.0.5
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Maven
uses: actions/setup-java@v2
with:
java-version: '15'
distribution: 'adopt'
- name: Retrieve commit info
run: |
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
id: commit_info
- name: Build package
run: mvn --batch-mode -Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}" clean compile -f pom.xml

31
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Deploy Artifact
on:
push:
branches:
- 'master'
- 'main'
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- name: Install thrift
uses: valitydev/action-setup-thrift@v0.0.5
- name: Checkout Repo
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Retrieve commit info
run: |
echo "::set-output name=COMMIT_NUMBER::$(git rev-list HEAD --count)"
echo "::set-output name=SHA_7::${GITHUB_SHA::7}"
id: commit_info
- name: Deploy package
uses: valitydev/action-deploy-jdk-package@v1.0.13
with:
server-username: ${{ secrets.OSSRH_USERNAME }}
server-password: ${{ secrets.OSSRH_TOKEN }}
deploy-secret-key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
deploy-secret-key-password: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
maven-args: '-Dcommit.number=${{ steps.commit_info.outputs.COMMIT_NUMBER }} -Drevision="1.${{ steps.commit_info.outputs.COMMIT_NUMBER }}-${{ steps.commit_info.outputs.SHA_7 }}"'

37
.github/workflows/erlang-pr.yml vendored Normal file
View File

@ -0,0 +1,37 @@
name: Erlang
on:
pull_request:
branches: [ '*' ]
push:
branches: [ master ]
jobs:
build:
name: Build and verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: valitydev/action-setup-thrift@b457b89c7e1e960ea354f510bce69a725d16c556
with:
thrift-version: '0.14.2'
- uses: erlef/setup-beam@v1.10
id: beam
with:
otp-version: '24'
rebar3-version: '3.18'
- name: Restore PLT cache
uses: actions/cache@v2
id: plt-cache
with:
key: |
${{ runner.os }}-${{ steps.beam.outputs.otp-version }}-plt
path: |
_build/default/rebar3_*_plt
- run: rebar3 compile
- run: rebar3 xref
- run: rebar3 dialyzer

81
.gitignore vendored Normal file
View File

@ -0,0 +1,81 @@
# Created by .ignore support plugin (hsz.mobi)
.eunit
deps
*.o
*.beam
*.plt
erl_crash.dump
ebin/*.beam
rel/example_project
.concrete/DEV_MODE
.rebar
include/*.hrl
src/*.erl
_build/
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/
.idea/workspace.xml
.idea/tasks.xml
.idea/dictionaries
.idea/vcs.xml
.idea/jsLibraryMappings.xml
# Sensitive or high-churn files:
.idea/dataSources.ids
.idea/dataSources.xml
.idea/dataSources.local.xml
.idea/sqlDataSources.xml
.idea/dynamic.xml
.idea/uiDesigner.xml
# Gradle:
.idea/gradle.xml
.idea/libraries
# Mongo Explorer plugin:
.idea/mongoSettings.xml
*.iws
*.ipr
*.iml
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
*.class
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.ear
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
env.list

176
LICENSE Normal file
View File

@ -0,0 +1,176 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS

3
README.md Normal file
View File

@ -0,0 +1,3 @@
# Skipper-proto
Протокол для сервиса работы с чарджбэками

126
pom.xml Normal file
View File

@ -0,0 +1,126 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>dev.vality</groupId>
<artifactId>library-parent-pom</artifactId>
<version>1.0.2</version>
</parent>
<artifactId>skipper-proto</artifactId>
<version>${revision}</version>
<packaging>jar</packaging>
<name>SkipperProto</name>
<description>Generates jar artifact containing compiled thrift classes based on generated thrift IDL files</description>
<url>https://github.com/valitydev/skipper-proto</url>
<licenses>
<license>
<name>The Apache Software License, Version 2.0</name>
<url>https://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>
<developers>
<developer>
<email>devs@vality.dev</email>
<organization>Vality</organization>
<organizationUrl>https://vality.dev</organizationUrl>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/valitydev/skipper-proto</connection>
<developerConnection>scm:git:ssh://github.com/valitydev/skipper-proto</developerConnection>
<url>https://github.com/valitydev/skipper-proto/tree/master</url>
</scm>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<revision>SNAPSHOT</revision>
</properties>
<dependencies>
<dependency>
<groupId>dev.vality.woody</groupId>
<artifactId>woody-thrift</artifactId>
<version>1.0.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>dev.vality</groupId>
<artifactId>damsel</artifactId>
<version>1.544-dcd92dd</version>
</dependency>
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>${project.basedir}/proto</directory>
<targetPath>${project.build.outputDirectory}/proto</targetPath>
<includes>
<include>*.thrift</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<!-- THRIFT -->
<plugin>
<groupId>org.apache.thrift</groupId>
<artifactId>thrift-maven-plugin</artifactId>
<version>0.10.0</version>
<configuration>
<generator>java:fullcamel</generator>
<thriftSourceRoot>${project.basedir}/proto</thriftSourceRoot>
<thriftExecutable>${path_to_thrift}</thriftExecutable>
</configuration>
<executions>
<execution>
<id>thrift-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<relocations>
<relocation>
<pattern>dev.vality.damsel</pattern>
<shadedPattern>dev.vality.damsel.v${commit.number}</shadedPattern>
</relocation>
</relocations>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>v${commit.number}</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

19
proto/base.thrift Normal file
View File

@ -0,0 +1,19 @@
namespace java dev.vality.damsel.skipper
namespace erlang skipper
typedef string ID
typedef string CardNumber
typedef i64 Number
typedef i64 Amount
typedef string Currency
typedef string Timestamp
struct Content {
1: required string type
2: required binary data
}

47
proto/chargeback.thrift Normal file
View File

@ -0,0 +1,47 @@
namespace java dev.vality.damsel.skipper
namespace erlang skipper
include "base.thrift"
union ChargebackCategory {
1: ChargebackCategoryFraud fraud
2: ChargebackCategoryDispute dispute
3: ChargebackCategoryAuthorisation authorisation
4: ChargebackCategoryProcessingError processing_error
}
struct ChargebackCategoryFraud {}
struct ChargebackCategoryDispute {}
struct ChargebackCategoryAuthorisation {}
struct ChargebackCategoryProcessingError {}
union ChargebackStage {
1: StageChargeback chargeback
2: StagePreArbitration pre_arbitration
3: StageArbitration arbitration
}
struct StageChargeback {}
struct StagePreArbitration {}
struct StageArbitration {}
union ChargebackStatus {
1: ChargebackPending pending
2: ChargebackAccepted accepted
3: ChargebackRejected rejected
4: ChargebackCancelled cancelled
}
struct ChargebackPending {}
struct ChargebackAccepted {
1: optional base.Amount levy_amount
2: optional base.Amount body_amount
}
struct ChargebackRejected {
1: optional base.Amount levy_amount
2: optional base.Amount body_amount
}
struct ChargebackCancelled {}

108
proto/skipper.thrift Normal file
View File

@ -0,0 +1,108 @@
namespace java dev.vality.damsel.skipper
namespace erlang skipper
include "base.thrift"
include "chargeback.thrift"
typedef base.ID ChargebackID
struct ChargebackGeneralData {
1: required base.Timestamp pretension_date
2: required base.ID provider_id
3: required base.Timestamp operation_date
4: required base.ID invoice_id
5: required base.ID payment_id
6: required base.ID chargeback_id
7: optional string rrn
8: optional string masked_pan
9: required base.Amount levy_amount
10: optional base.Amount body_amount
11: required base.Currency currency
12: optional string shop_url
13: optional string party_email
14: optional string contact_email
15: required base.ID shop_id
16: required base.ID external_id
17: optional ChargebackReason chargeback_reason
18: optional base.Content content
19: required bool retrieval_request
}
struct ChargebackReason {
1: optional base.ID code
2: required chargeback.ChargebackCategory category
}
union ChargebackEvent {
1: ChargebackCreateEvent create_event
2: ChargebackStatusChangeEvent status_change_event
3: ChargebackHoldStatusChangeEvent hold_status_change_event
4: ChargebackReopenEvent reopen_event
}
struct ChargebackCreateEvent {
1: required ChargebackGeneralData creation_data
2: optional ChargebackStatusChangeEvent status_change_event
3: optional ChargebackHoldStatusChangeEvent hold_status_change_event
}
struct ChargebackStatusChangeEvent {
1: required base.ID invoice_id
2: required base.ID payment_id
3: required base.ID chargeback_id
4: required chargeback.ChargebackStatus status
5: optional chargeback.ChargebackStage stage
6: required base.Timestamp created_at
7: optional base.Timestamp date_of_decision
}
struct ChargebackHoldStatusChangeEvent {
1: required base.ID invoice_id
2: required base.ID payment_id
3: required base.ID chargeback_id
4: required base.Timestamp created_at
5: required ChargebackHoldStatus hold_status
}
struct ChargebackHoldStatus {
1: optional bool will_hold_from_merchant
2: optional bool was_hold_from_merchant
3: optional bool hold_from_us
}
struct ChargebackReopenEvent {
1: required base.ID invoice_id
2: required base.ID payment_id
3: required base.ID chargeback_id
4: required base.Timestamp created_at
5: optional base.Amount levy_amount
6: optional base.Amount body_amount
7: optional chargeback.ChargebackStage reopen_stage
}
struct ChargebackData {
1: required ChargebackID id
2: required list<ChargebackEvent> events
}
struct ChargebackFilter {
1: required base.Timestamp date_from
2: optional base.Timestamp date_to
3: optional string provider_id
4: optional list<chargeback.ChargebackStage> stages
5: optional list<chargeback.ChargebackStatus> statuses
}
/** Service for work with chargebacks */
service Skipper {
void processChargebackData(1: ChargebackEvent event)
ChargebackData getChargebackData(1: base.ID invoice_id, 2: base.ID payment_id, 3: base.ID chargeback_id)
ChargebackData getRetrievalRequestData(1: base.ID invoice_id, 2: base.ID payment_id, 3: base.ID chargeback_id)
list<ChargebackData> getChargebacks(1: ChargebackFilter filter)
}

78
rebar.config Normal file
View File

@ -0,0 +1,78 @@
%% Common project erlang options.
{erl_opts, [
% mandatory
debug_info,
warnings_as_errors,
warn_export_all,
warn_missing_spec,
warn_untyped_record,
warn_export_vars,
% by default
warn_unused_record,
warn_bif_clash,
warn_obsolete_guard,
warn_unused_vars,
warn_shadow_vars,
warn_unused_import,
warn_unused_function,
warn_deprecated_function,
% at will
% bin_opt_info
% no_auto_import,
warn_missing_spec_all
]}.
{deps, [
{damsel,
{git, "https://github.com/valitydev/damsel.git",
{branch, "master"}}
},
{payout_manager_proto,
{git, "https://github.com/valitydev/payout-manager-proto.git",
{branch, "master"}}
}
]}.
%% XRef checks
{xref_checks, [
undefined_function_calls,
undefined_functions,
deprecated_functions_calls,
deprecated_functions
]}.
%% Tests
{cover_enabled, true}.
%% Dialyzer static analyzing
{dialyzer, [
{warnings, [
% mandatory
unmatched_returns,
error_handling,
race_conditions,
unknown
]},
{plt_apps, all_deps}
]}.
{plugins, [
{rebar3_thrift_compiler,
{git, "https://github.com/valitydev/rebar3_thrift_compiler.git", {branch, "master"}}}
]}.
{provider_hooks, [
{pre, [
{compile, {thrift, compile}},
{clean , {thrift, clean }}
]}
]}.
{thrift_compiler_opts, [
{in_dir, "proto"},
{in_files, all},
{gen, "erlang:scoped_typenames"}
]}.

8
rebar.lock Normal file
View File

@ -0,0 +1,8 @@
[{<<"damsel">>,
{git,"https://github.com/valitydev/damsel.git",
{ref,"5addc419f26de2cd00294865feea3d997d308d77"}},
0},
{<<"payout_manager_proto">>,
{git,"https://github.com/valitydev/payout-manager-proto.git",
{ref,"5bf4fad7183e34b9ef0e53be86c524ea2ae121ad"}},
0}].

18
renovate.json Normal file
View File

@ -0,0 +1,18 @@
{
"extends": [
"config:base"
],
"packageRules": [
{
"matchPackagePatterns": [
"*"
],
"matchUpdateTypes": [
"minor",
"patch"
],
"groupName": "all non-major dependencies",
"groupSlug": "all-minor-patch"
}
]
}

View File

@ -0,0 +1,8 @@
{application, skipper_proto, [
{description, "Thrift proto for skipper"},
{vsn, "0.1.0"},
{applications, [
kernel,
stdlib
]}
]}.