spree_packeta 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/release.yml +196 -0
- data/.github/workflows/test.yml +61 -0
- data/.gitignore +63 -0
- data/CHANGELOG.md +43 -0
- data/COMMANDS.md +322 -0
- data/Gemfile +13 -0
- data/LICENSE +21 -0
- data/README.md +307 -0
- data/app/decorators/spree/order_decorator.rb +44 -0
- data/app/decorators/spree/shipment_decorator.rb +65 -0
- data/db/migrate/20241206000001_add_packeta_tracking_to_shipments.rb +14 -0
- data/docs/RELEASING.md +421 -0
- data/lib/generators/spree_packeta/install_generator.rb +68 -0
- data/lib/generators/spree_packeta/templates/initializer.rb +39 -0
- data/lib/spree_packeta/configuration.rb +55 -0
- data/lib/spree_packeta/engine.rb +48 -0
- data/lib/spree_packeta/models/shipping_calculator.rb +54 -0
- data/lib/spree_packeta/models/shipping_method.rb +59 -0
- data/lib/spree_packeta/services/packet_creator.rb +98 -0
- data/lib/spree_packeta/services/tracker.rb +96 -0
- data/lib/spree_packeta/soap/client.rb +117 -0
- data/lib/spree_packeta/soap/operations.rb +140 -0
- data/lib/spree_packeta/soap/packeta.wsdl +1819 -0
- data/lib/spree_packeta/version.rb +5 -0
- data/lib/spree_packeta.rb +18 -0
- data/lib/tasks/spree_packeta.rake +293 -0
- data/spree_packeta.gemspec +41 -0
- metadata +228 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a99485f4b3f4e3cdfcf8c6190029b60f3264af5382f8322fe0ac8a50ba3a0749
|
|
4
|
+
data.tar.gz: a3626fae18789cf4810e87dd8079401a431cb005a8ad421b7a4d300521b1ff41
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4be22a237a3f1aad4cb160dc6835ac9c2bea64354d6304bb85c6a491f0dbc5a6160b0ecd3e8820a36f71ca56cc02212e8ed422fc0d506a5644c239f5df77dde0
|
|
7
|
+
data.tar.gz: b3a3d1b141afdce86a3cb09df36170129c5231ad0fc6b6d03a5ec4f77d6a36f327c188f80df614c4c9abd771af5afdc5b99de621b1926d3f84ce54772d569586
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
name: Release Gem to RubyGems and GitHub Packages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v[0-9]+.[0-9]+.[0-9]+'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
packages: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
validate:
|
|
14
|
+
name: Validate Release
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
outputs:
|
|
17
|
+
version: ${{ steps.get_version.outputs.version }}
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Extract version from tag
|
|
24
|
+
id: get_version
|
|
25
|
+
run: |
|
|
26
|
+
TAG=${GITHUB_REF#refs/tags/v}
|
|
27
|
+
echo "version=$TAG" >> $GITHUB_OUTPUT
|
|
28
|
+
echo "Tag version: $TAG"
|
|
29
|
+
|
|
30
|
+
- name: Validate version consistency
|
|
31
|
+
run: |
|
|
32
|
+
TAG_VERSION="${{ steps.get_version.outputs.version }}"
|
|
33
|
+
FILE_VERSION=$(grep -E "VERSION = ['\"]" lib/spree_packeta/version.rb | sed "s/.*['\"]\\(.*\\)['\"].*/\\1/")
|
|
34
|
+
|
|
35
|
+
echo "Tag version: $TAG_VERSION"
|
|
36
|
+
echo "File version: $FILE_VERSION"
|
|
37
|
+
|
|
38
|
+
if [ "$TAG_VERSION" != "$FILE_VERSION" ]; then
|
|
39
|
+
echo "❌ ERROR: Version mismatch!"
|
|
40
|
+
echo "Git tag: v$TAG_VERSION"
|
|
41
|
+
echo "version.rb: $FILE_VERSION"
|
|
42
|
+
echo ""
|
|
43
|
+
echo "Please update lib/spree_packeta/version.rb to match the tag version."
|
|
44
|
+
exit 1
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
echo "✅ Version validation passed"
|
|
48
|
+
|
|
49
|
+
test:
|
|
50
|
+
name: Run Tests
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
needs: validate
|
|
53
|
+
|
|
54
|
+
steps:
|
|
55
|
+
- name: Checkout code
|
|
56
|
+
uses: actions/checkout@v4
|
|
57
|
+
|
|
58
|
+
- name: Set up Ruby
|
|
59
|
+
uses: ruby/setup-ruby@v1
|
|
60
|
+
with:
|
|
61
|
+
ruby-version: '3.1'
|
|
62
|
+
bundler-cache: true
|
|
63
|
+
|
|
64
|
+
- name: Install dependencies
|
|
65
|
+
run: bundle install
|
|
66
|
+
|
|
67
|
+
- name: Run RSpec tests
|
|
68
|
+
run: bundle exec rspec
|
|
69
|
+
|
|
70
|
+
- name: Run RuboCop (if configured)
|
|
71
|
+
run: bundle exec rubocop || true
|
|
72
|
+
continue-on-error: true
|
|
73
|
+
|
|
74
|
+
release:
|
|
75
|
+
name: Build and Publish Gem
|
|
76
|
+
runs-on: ubuntu-latest
|
|
77
|
+
needs: [validate, test]
|
|
78
|
+
|
|
79
|
+
steps:
|
|
80
|
+
- name: Checkout code
|
|
81
|
+
uses: actions/checkout@v4
|
|
82
|
+
|
|
83
|
+
- name: Set up Ruby
|
|
84
|
+
uses: ruby/setup-ruby@v1
|
|
85
|
+
with:
|
|
86
|
+
ruby-version: '3.1'
|
|
87
|
+
bundler-cache: true
|
|
88
|
+
|
|
89
|
+
- name: Build gem
|
|
90
|
+
run: |
|
|
91
|
+
gem build spree_packeta.gemspec
|
|
92
|
+
echo "✅ Gem built successfully"
|
|
93
|
+
ls -lh *.gem
|
|
94
|
+
|
|
95
|
+
- name: Configure RubyGems credentials
|
|
96
|
+
run: |
|
|
97
|
+
mkdir -p ~/.gem
|
|
98
|
+
cat > ~/.gem/credentials << EOF
|
|
99
|
+
---
|
|
100
|
+
:rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}
|
|
101
|
+
:github: Bearer ${{ secrets.GITHUB_TOKEN }}
|
|
102
|
+
EOF
|
|
103
|
+
chmod 0600 ~/.gem/credentials
|
|
104
|
+
|
|
105
|
+
- name: Publish to RubyGems.org
|
|
106
|
+
run: |
|
|
107
|
+
gem push spree_packeta-*.gem
|
|
108
|
+
echo "✅ Gem published to RubyGems.org"
|
|
109
|
+
|
|
110
|
+
- name: Publish to GitHub Packages
|
|
111
|
+
continue-on-error: true
|
|
112
|
+
run: |
|
|
113
|
+
# Extract owner from repository (owner/repo -> owner)
|
|
114
|
+
OWNER=$(echo "${{ github.repository }}" | cut -d'/' -f1)
|
|
115
|
+
|
|
116
|
+
gem push --key github --host https://rubygems.pkg.github.com/${OWNER} spree_packeta-*.gem
|
|
117
|
+
echo "✅ Gem published to GitHub Packages"
|
|
118
|
+
|
|
119
|
+
- name: Generate release notes
|
|
120
|
+
id: release_notes
|
|
121
|
+
run: |
|
|
122
|
+
VERSION="${{ needs.validate.outputs.version }}"
|
|
123
|
+
|
|
124
|
+
# Get previous tag
|
|
125
|
+
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
126
|
+
|
|
127
|
+
if [ -z "$PREV_TAG" ]; then
|
|
128
|
+
echo "First release - generating from all commits"
|
|
129
|
+
COMMITS=$(git log --pretty=format:"- %s (%h)" --no-merges)
|
|
130
|
+
else
|
|
131
|
+
echo "Generating changelog from $PREV_TAG to v$VERSION"
|
|
132
|
+
COMMITS=$(git log $PREV_TAG..HEAD --pretty=format:"- %s (%h)" --no-merges)
|
|
133
|
+
fi
|
|
134
|
+
|
|
135
|
+
# Create release notes file
|
|
136
|
+
cat > release_notes.md << EOF
|
|
137
|
+
## What's Changed
|
|
138
|
+
|
|
139
|
+
$COMMITS
|
|
140
|
+
|
|
141
|
+
## Installation
|
|
142
|
+
|
|
143
|
+
### From RubyGems.org
|
|
144
|
+
|
|
145
|
+
Add to your Gemfile:
|
|
146
|
+
|
|
147
|
+
\`\`\`ruby
|
|
148
|
+
gem 'spree_packeta', '~> $VERSION'
|
|
149
|
+
\`\`\`
|
|
150
|
+
|
|
151
|
+
### From GitHub Packages
|
|
152
|
+
|
|
153
|
+
Configure bundler to use GitHub Packages:
|
|
154
|
+
|
|
155
|
+
\`\`\`ruby
|
|
156
|
+
# Gemfile
|
|
157
|
+
source 'https://rubygems.pkg.github.com/${{ github.repository_owner }}' do
|
|
158
|
+
gem 'spree_packeta', '~> $VERSION'
|
|
159
|
+
end
|
|
160
|
+
\`\`\`
|
|
161
|
+
|
|
162
|
+
Then run:
|
|
163
|
+
|
|
164
|
+
\`\`\`bash
|
|
165
|
+
bundle install
|
|
166
|
+
bundle exec rails g spree_packeta:install
|
|
167
|
+
\`\`\`
|
|
168
|
+
|
|
169
|
+
## Documentation
|
|
170
|
+
|
|
171
|
+
See the [README](https://github.com/${{ github.repository }}/blob/main/README.md) for complete documentation.
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
**Full Changelog**: https://github.com/${{ github.repository }}/compare/$PREV_TAG...v$VERSION
|
|
176
|
+
EOF
|
|
177
|
+
|
|
178
|
+
cat release_notes.md
|
|
179
|
+
|
|
180
|
+
- name: Create GitHub Release
|
|
181
|
+
env:
|
|
182
|
+
GH_TOKEN: ${{ github.token }}
|
|
183
|
+
run: |
|
|
184
|
+
VERSION="${{ needs.validate.outputs.version }}"
|
|
185
|
+
|
|
186
|
+
gh release create "v$VERSION" \
|
|
187
|
+
--title "Release v$VERSION" \
|
|
188
|
+
--notes-file release_notes.md \
|
|
189
|
+
--verify-tag \
|
|
190
|
+
spree_packeta-*.gem
|
|
191
|
+
|
|
192
|
+
echo "✅ GitHub Release created"
|
|
193
|
+
|
|
194
|
+
- name: Cleanup credentials
|
|
195
|
+
if: always()
|
|
196
|
+
run: rm -f ~/.gem/credentials
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main, master, develop]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main, master, develop]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Test (Ruby ${{ matrix.ruby }})
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
ruby: ['3.1', '3.2']
|
|
18
|
+
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout code
|
|
21
|
+
uses: actions/checkout@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Ruby
|
|
24
|
+
uses: ruby/setup-ruby@v1
|
|
25
|
+
with:
|
|
26
|
+
ruby-version: ${{ matrix.ruby }}
|
|
27
|
+
bundler-cache: true
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: bundle install
|
|
31
|
+
|
|
32
|
+
- name: Run RSpec
|
|
33
|
+
run: bundle exec rspec
|
|
34
|
+
|
|
35
|
+
- name: Run RuboCop
|
|
36
|
+
run: bundle exec rubocop
|
|
37
|
+
continue-on-error: true
|
|
38
|
+
|
|
39
|
+
build:
|
|
40
|
+
name: Build Gem
|
|
41
|
+
runs-on: ubuntu-latest
|
|
42
|
+
|
|
43
|
+
steps:
|
|
44
|
+
- name: Checkout code
|
|
45
|
+
uses: actions/checkout@v4
|
|
46
|
+
|
|
47
|
+
- name: Set up Ruby
|
|
48
|
+
uses: ruby/setup-ruby@v1
|
|
49
|
+
with:
|
|
50
|
+
ruby-version: '3.1'
|
|
51
|
+
|
|
52
|
+
- name: Build gem
|
|
53
|
+
run: gem build spree_packeta.gemspec
|
|
54
|
+
|
|
55
|
+
- name: Verify gem contents
|
|
56
|
+
run: |
|
|
57
|
+
echo "Gem specification:"
|
|
58
|
+
gem spec spree_packeta-*.gem
|
|
59
|
+
echo ""
|
|
60
|
+
echo "Gem contents:"
|
|
61
|
+
tar -tzf spree_packeta-*.gem | head -20
|
data/.gitignore
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
/.config
|
|
4
|
+
/coverage/
|
|
5
|
+
/InstalledFiles
|
|
6
|
+
/pkg/
|
|
7
|
+
/spec/reports/
|
|
8
|
+
/spec/examples.txt
|
|
9
|
+
/test/tmp/
|
|
10
|
+
/test/version_tmp/
|
|
11
|
+
/tmp/
|
|
12
|
+
|
|
13
|
+
# Used by dotenv library to load environment variables.
|
|
14
|
+
.env
|
|
15
|
+
|
|
16
|
+
# Ignore Byebug command history file.
|
|
17
|
+
.byebug_history
|
|
18
|
+
|
|
19
|
+
## Specific to RubyMotion:
|
|
20
|
+
.dat*
|
|
21
|
+
.repl_history
|
|
22
|
+
build/
|
|
23
|
+
*.bridgesupport
|
|
24
|
+
build-iPhoneOS/
|
|
25
|
+
build-iPhoneSimulator/
|
|
26
|
+
|
|
27
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
28
|
+
Pods/
|
|
29
|
+
vendor/bundle/
|
|
30
|
+
|
|
31
|
+
## Documentation cache and generated files:
|
|
32
|
+
/.yardoc/
|
|
33
|
+
/_yardoc/
|
|
34
|
+
/doc/
|
|
35
|
+
/rdoc/
|
|
36
|
+
|
|
37
|
+
## Environment normalization:
|
|
38
|
+
/.bundle/
|
|
39
|
+
/vendor/bundle
|
|
40
|
+
/lib/bundler/man/
|
|
41
|
+
|
|
42
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
43
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
44
|
+
Gemfile.lock
|
|
45
|
+
.ruby-version
|
|
46
|
+
.ruby-gemset
|
|
47
|
+
|
|
48
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
49
|
+
.rvmrc
|
|
50
|
+
|
|
51
|
+
# RSpec
|
|
52
|
+
.rspec_status
|
|
53
|
+
|
|
54
|
+
# IDE
|
|
55
|
+
.idea/
|
|
56
|
+
.vscode/
|
|
57
|
+
*.swp
|
|
58
|
+
*.swo
|
|
59
|
+
*~
|
|
60
|
+
|
|
61
|
+
# OS
|
|
62
|
+
.DS_Store
|
|
63
|
+
Thumbs.db
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
## [0.1.0] - 2024-12-21
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- Initial release of spree_packeta gem
|
|
16
|
+
- SOAP client wrapper for Packeta API
|
|
17
|
+
- Packet creation and tracking functionality
|
|
18
|
+
- Shipping method and calculator integration
|
|
19
|
+
- Database tracking fields for shipments (packet_id, barcode, status_code, etc.)
|
|
20
|
+
- Installation generator (`rails g spree_packeta:install`)
|
|
21
|
+
- Rake tasks for installation and status checking
|
|
22
|
+
- RSpec test suite with VCR cassettes for API testing
|
|
23
|
+
- Configuration system with environment variable support
|
|
24
|
+
- Error handling with custom exception classes
|
|
25
|
+
- Support for Czech Republic and EU shipping zones
|
|
26
|
+
- Automated gem release workflow via GitHub Actions
|
|
27
|
+
- Dual publishing to RubyGems.org and GitHub Packages
|
|
28
|
+
- CHANGELOG.md for tracking version history
|
|
29
|
+
- Release documentation in docs/RELEASING.md
|
|
30
|
+
- CI workflow for running tests on PRs and commits
|
|
31
|
+
|
|
32
|
+
### Features
|
|
33
|
+
- Create packets via Packeta SOAP API
|
|
34
|
+
- Track packet status and history
|
|
35
|
+
- Integration with Spree Commerce shipping system
|
|
36
|
+
- Configurable API credentials and endpoints
|
|
37
|
+
- Sender information for return labels
|
|
38
|
+
- Rate caching support
|
|
39
|
+
- Auto-create packets on shipment option
|
|
40
|
+
- Tracking sync interval configuration
|
|
41
|
+
|
|
42
|
+
[Unreleased]: https://github.com/yourusername/spree_packeta/compare/v0.1.0...HEAD
|
|
43
|
+
[0.1.0]: https://github.com/yourusername/spree_packeta/releases/tag/v0.1.0
|
data/COMMANDS.md
ADDED
|
@@ -0,0 +1,322 @@
|
|
|
1
|
+
# Spree Packeta Commands Reference
|
|
2
|
+
|
|
3
|
+
Quick reference for all available commands and utilities.
|
|
4
|
+
|
|
5
|
+
## Installation & Setup
|
|
6
|
+
|
|
7
|
+
### Generator
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Full installation (interactive)
|
|
11
|
+
rails g spree_packeta:install
|
|
12
|
+
|
|
13
|
+
# Auto-run migrations without prompting
|
|
14
|
+
rails g spree_packeta:install --auto-run-migrations
|
|
15
|
+
|
|
16
|
+
# Skip shipping method installation
|
|
17
|
+
rails g spree_packeta:install --skip-shipping-method
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
This will:
|
|
21
|
+
- Create initializer at `config/initializers/spree_packeta.rb`
|
|
22
|
+
- Copy migration files
|
|
23
|
+
- Optionally run migrations
|
|
24
|
+
- Optionally install shipping method
|
|
25
|
+
|
|
26
|
+
### Migrations
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Copy migrations only
|
|
30
|
+
rails spree_packeta:install:migrations
|
|
31
|
+
|
|
32
|
+
# Run migrations
|
|
33
|
+
rails db:migrate
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Shipping Method Management
|
|
37
|
+
|
|
38
|
+
### Install Shipping Method
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
rake spree_packeta:install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Creates a ready-to-use Packeta shipping method with:
|
|
45
|
+
- Name: "Packeta"
|
|
46
|
+
- Admin Name: "Packeta (Zásilkovna)"
|
|
47
|
+
- Code: "packeta"
|
|
48
|
+
- Tracking URL: `https://tracking.packeta.com/:tracking`
|
|
49
|
+
- Calculator: Packeta Shipping Calculator (99 CZK base rate)
|
|
50
|
+
- Zones: Czech Republic + EU
|
|
51
|
+
- Display: Both frontend and backend
|
|
52
|
+
|
|
53
|
+
**Output example:**
|
|
54
|
+
```
|
|
55
|
+
Installing Packeta shipping method...
|
|
56
|
+
✓ Created default shipping category
|
|
57
|
+
✓ Created Czech Republic zone
|
|
58
|
+
✓ Created EU zone
|
|
59
|
+
✓ Created Packeta shipping method (ID: 42)
|
|
60
|
+
✓ Assigned to zones: Czech Republic, EU
|
|
61
|
+
✓ Base rate: 99.0 CZK
|
|
62
|
+
|
|
63
|
+
✅ Packeta shipping method installed successfully!
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Check Status
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
rake spree_packeta:status
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Shows:
|
|
73
|
+
- Installation status
|
|
74
|
+
- Shipping method details
|
|
75
|
+
- Zone assignments
|
|
76
|
+
- Calculator configuration
|
|
77
|
+
- Configuration status (API credentials, etc.)
|
|
78
|
+
|
|
79
|
+
**Output example:**
|
|
80
|
+
```
|
|
81
|
+
Packeta Shipping Method Status
|
|
82
|
+
==================================================
|
|
83
|
+
✅ Installed (ID: 42)
|
|
84
|
+
|
|
85
|
+
Name: Packeta
|
|
86
|
+
Admin Name: Packeta (Zásilkovna)
|
|
87
|
+
Display On: both
|
|
88
|
+
Available: Yes
|
|
89
|
+
Calculator: SpreePacketa::Models::ShippingCalculator
|
|
90
|
+
Zones: Czech Republic, EU
|
|
91
|
+
Categories: Default
|
|
92
|
+
Base Rate: 99.0 CZK
|
|
93
|
+
|
|
94
|
+
Configuration Status
|
|
95
|
+
==================================================
|
|
96
|
+
✅ API Password : abc123...
|
|
97
|
+
✅ SOAP Endpoint : http://www.zasilkovna.cz/api/soap
|
|
98
|
+
✅ WSDL Path : file:///Users/oezr/Downloads/soap.wsdl
|
|
99
|
+
✅ Eshop ID : my-eshop
|
|
100
|
+
✅ Sender Email : shipping@mystore.com
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Uninstall Shipping Method
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
rake spree_packeta:uninstall
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Removes all Packeta shipping methods from the database.
|
|
110
|
+
|
|
111
|
+
## Rails Console Usage
|
|
112
|
+
|
|
113
|
+
### Configuration
|
|
114
|
+
|
|
115
|
+
```ruby
|
|
116
|
+
# Check current configuration
|
|
117
|
+
SpreePacketa.configuration
|
|
118
|
+
|
|
119
|
+
# Update configuration
|
|
120
|
+
SpreePacketa.configure do |config|
|
|
121
|
+
config.api_password = 'new_password'
|
|
122
|
+
config.eshop = 'new_eshop_id'
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# Reset to defaults
|
|
126
|
+
SpreePacketa.reset_configuration!
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### SOAP Operations
|
|
130
|
+
|
|
131
|
+
```ruby
|
|
132
|
+
# Initialize operations
|
|
133
|
+
ops = SpreePacketa::Soap::Operations.new
|
|
134
|
+
|
|
135
|
+
# Create a packet
|
|
136
|
+
packet = ops.create_packet(
|
|
137
|
+
number: 'ORDER-123',
|
|
138
|
+
name: 'John',
|
|
139
|
+
surname: 'Doe',
|
|
140
|
+
email: 'john@example.com',
|
|
141
|
+
phone: '+420123456789',
|
|
142
|
+
address_id: 1234,
|
|
143
|
+
value: 1000.0,
|
|
144
|
+
weight: 2.5,
|
|
145
|
+
currency: 'CZK'
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
# Get packet status
|
|
149
|
+
status = ops.packet_status(packet[:id])
|
|
150
|
+
|
|
151
|
+
# Get tracking history
|
|
152
|
+
history = ops.packet_tracking(packet[:id])
|
|
153
|
+
|
|
154
|
+
# Cancel packet
|
|
155
|
+
ops.cancel_packet(packet[:id])
|
|
156
|
+
|
|
157
|
+
# Get label PDF
|
|
158
|
+
pdf = ops.packet_label_pdf(packet[:id], format: 'A7 on A4')
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Services
|
|
162
|
+
|
|
163
|
+
```ruby
|
|
164
|
+
# Create packet from shipment
|
|
165
|
+
shipment = Spree::Shipment.find(123)
|
|
166
|
+
creator = SpreePacketa::Services::PacketCreator.new(shipment)
|
|
167
|
+
packet = creator.create_packet
|
|
168
|
+
|
|
169
|
+
# Track shipment
|
|
170
|
+
tracker = SpreePacketa::Services::Tracker.new(shipment)
|
|
171
|
+
status = tracker.current_status
|
|
172
|
+
history = tracker.tracking_history
|
|
173
|
+
tracker.sync_status!
|
|
174
|
+
|
|
175
|
+
# Check if needs sync
|
|
176
|
+
tracker.needs_sync? # => true/false
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Order Metadata
|
|
180
|
+
|
|
181
|
+
```ruby
|
|
182
|
+
# Get order's pickup point
|
|
183
|
+
order = Spree::Order.find_by(number: 'R123456789')
|
|
184
|
+
order.packeta_pickup_point_id # => "12345"
|
|
185
|
+
order.packeta_pickup_point_name # => "Packeta Point - Prague"
|
|
186
|
+
order.packeta_address_id # => 12345 (as integer)
|
|
187
|
+
|
|
188
|
+
# Set pickup point
|
|
189
|
+
order.set_packeta_pickup_point({
|
|
190
|
+
id: 12345,
|
|
191
|
+
name: 'Packeta Point - Prague',
|
|
192
|
+
street: 'Main Street 123',
|
|
193
|
+
city: 'Prague',
|
|
194
|
+
zip: '11000'
|
|
195
|
+
})
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Shipment Tracking
|
|
199
|
+
|
|
200
|
+
```ruby
|
|
201
|
+
# Get shipment with Packeta data
|
|
202
|
+
shipment = Spree::Shipment.find(123)
|
|
203
|
+
shipment.packeta_packet_id # => 987654321
|
|
204
|
+
shipment.packeta_barcode # => "Z123456789"
|
|
205
|
+
shipment.packeta_tracking_url # => "https://tracking.packeta.com/987654321"
|
|
206
|
+
shipment.packeta_status_code # => 3
|
|
207
|
+
shipment.packeta_branch_id # => 1234
|
|
208
|
+
shipment.packeta_last_sync_at # => 2024-12-06 10:30:00 UTC
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
## Testing & Development
|
|
212
|
+
|
|
213
|
+
### Check SOAP Connection
|
|
214
|
+
|
|
215
|
+
```ruby
|
|
216
|
+
# In Rails console
|
|
217
|
+
client = SpreePacketa::Soap::Client.new
|
|
218
|
+
operations = client.call(:packet_status, packet_id: 123456)
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Validate Configuration
|
|
222
|
+
|
|
223
|
+
```ruby
|
|
224
|
+
# Check all required config is set
|
|
225
|
+
config = SpreePacketa.configuration
|
|
226
|
+
|
|
227
|
+
puts "API Password: #{config.api_password.present? ? '✓' : '✗'}"
|
|
228
|
+
puts "SOAP Endpoint: #{config.soap_endpoint.present? ? '✓' : '✗'}"
|
|
229
|
+
puts "WSDL Path: #{config.wsdl_path.present? ? '✓' : '✗'}"
|
|
230
|
+
puts "Eshop: #{config.eshop.present? ? '✓' : '✗'}"
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Test Packet Creation
|
|
234
|
+
|
|
235
|
+
```ruby
|
|
236
|
+
# Test with sample data
|
|
237
|
+
ops = SpreePacketa::Soap::Operations.new
|
|
238
|
+
|
|
239
|
+
# Validate before creating
|
|
240
|
+
begin
|
|
241
|
+
ops.packet_attributes_valid?(
|
|
242
|
+
number: 'TEST-001',
|
|
243
|
+
name: 'Test',
|
|
244
|
+
surname: 'User',
|
|
245
|
+
email: 'test@example.com',
|
|
246
|
+
phone: '+420123456789',
|
|
247
|
+
address_id: 1234,
|
|
248
|
+
value: 100.0,
|
|
249
|
+
weight: 1.0,
|
|
250
|
+
currency: 'CZK'
|
|
251
|
+
)
|
|
252
|
+
puts "✓ Attributes are valid"
|
|
253
|
+
rescue SpreePacketa::ValidationError => e
|
|
254
|
+
puts "✗ Validation failed: #{e.message}"
|
|
255
|
+
end
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
## Troubleshooting Commands
|
|
259
|
+
|
|
260
|
+
### Check Gem Loading
|
|
261
|
+
|
|
262
|
+
```ruby
|
|
263
|
+
# In Rails console
|
|
264
|
+
puts SpreePacketa::VERSION
|
|
265
|
+
puts Spree::ShippingMethod.include?(SpreePacketa::Models::ShippingMethod)
|
|
266
|
+
puts Spree::Order.instance_methods.include?(:packeta_address_id)
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
### Check Database Columns
|
|
270
|
+
|
|
271
|
+
```bash
|
|
272
|
+
# Check if migration ran
|
|
273
|
+
rails runner "puts ActiveRecord::Base.connection.column_exists?(:spree_shipments, :packeta_packet_id)"
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### Reset Everything
|
|
277
|
+
|
|
278
|
+
```bash
|
|
279
|
+
# Remove shipping method
|
|
280
|
+
rake spree_packeta:uninstall
|
|
281
|
+
|
|
282
|
+
# Rollback migration (optional)
|
|
283
|
+
rails db:rollback
|
|
284
|
+
|
|
285
|
+
# Reinstall
|
|
286
|
+
rake spree_packeta:install
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Environment Variables
|
|
290
|
+
|
|
291
|
+
Required for production:
|
|
292
|
+
|
|
293
|
+
```bash
|
|
294
|
+
# .env or environment
|
|
295
|
+
PACKETA_API_PASSWORD=your_api_password_here
|
|
296
|
+
PACKETA_ESHOP=your_eshop_id
|
|
297
|
+
PACKETA_SENDER_EMAIL=shipping@yourstore.com
|
|
298
|
+
|
|
299
|
+
# Optional
|
|
300
|
+
PACKETA_SOAP_ENDPOINT=http://www.zasilkovna.cz/api/soap
|
|
301
|
+
PACKETA_WSDL_PATH=file:///path/to/soap.wsdl
|
|
302
|
+
PACKETA_SENDER_NAME=Your Store Name
|
|
303
|
+
PACKETA_SENDER_PHONE=+420123456789
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
## Quick Reference
|
|
307
|
+
|
|
308
|
+
| Task | Command |
|
|
309
|
+
|------|---------|
|
|
310
|
+
| Full install (interactive) | `rails g spree_packeta:install` |
|
|
311
|
+
| Install shipping method | `rake spree_packeta:install` |
|
|
312
|
+
| Check status | `rake spree_packeta:status` |
|
|
313
|
+
| Uninstall shipping method | `rake spree_packeta:uninstall` |
|
|
314
|
+
| Copy migrations | `rails spree_packeta:install:migrations` |
|
|
315
|
+
| Run migrations | `rails db:migrate` |
|
|
316
|
+
| Open console | `rails console` |
|
|
317
|
+
|
|
318
|
+
## See Also
|
|
319
|
+
|
|
320
|
+
- **README.md** - General documentation
|
|
321
|
+
- **FRONTEND_INTEGRATION.md** - React/frontend setup
|
|
322
|
+
- [Packeta API Docs](https://docs.packeta.com/)
|
data/Gemfile
ADDED