Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
f12099e
wip
k4th Aug 5, 2024
75e162c
wip
k4th Aug 5, 2024
19775a7
wip
k4th Aug 5, 2024
2516fa5
wip
k4th Aug 6, 2024
754fa04
wip
k4th Aug 6, 2024
c69d9d3
adds some endpoints
citin Aug 6, 2024
0f5ac37
require created files
citin Aug 6, 2024
b4455ec
Merge pull request #1 from citin/v2
k4th Aug 6, 2024
a30d087
Add endpoints
k4th Aug 6, 2024
3446eac
wip
k4th Aug 6, 2024
c089f9b
removes configs and refactor response
citin Aug 6, 2024
cb64540
Beyond api v2 (#63)
k4th Aug 6, 2024
84818d0
adds zeitwerk
citin Aug 6, 2024
7e5b115
V2 (#62)
k4th Aug 6, 2024
28f075d
Update fetch all (#64)
k4th Aug 6, 2024
96293f3
[wip] refactor connection and request
citin Aug 7, 2024
22a7403
Merge branch 'v2' of github.com:ePages-de/beyond_api-ruby_client into v2
citin Aug 7, 2024
51b8621
[WIP] refactor connection
citin Aug 7, 2024
3f06cc0
[WIP] refactor token call
citin Aug 7, 2024
ed0d19d
Wip v2 (#65)
k4th Aug 7, 2024
d12cdce
[WIP] add authentication
citin Aug 7, 2024
ca812fc
Wip v2 (#66)
k4th Aug 7, 2024
e2eaadc
refactor session, add autentication types (#67)
citin Aug 8, 2024
d4af644
Add webhook and signer endpoints (#68)
k4th Aug 8, 2024
d5ea45b
merge-pagination
citin Aug 8, 2024
c242501
Merge pull request #70 from citin/merge-pagination
citin Aug 8, 2024
e4de87e
adds parsed parameters in request
citin Aug 8, 2024
0e62e25
add @camelize_keys to connection
citin Aug 8, 2024
544df57
removes old /resources files
citin Aug 8, 2024
4b5ff93
update gem config and some linters
citin Aug 9, 2024
4128c2b
Update README.md
k4th Aug 13, 2024
ca15e56
Update README.md
k4th Aug 13, 2024
381f4d6
Update README.md
k4th Aug 13, 2024
a10d159
update dependencies definition
citin Aug 13, 2024
ff67041
adds error handling
citin Aug 13, 2024
4602916
Update README.md
k4th Aug 14, 2024
72606fe
Add tests
k4th Aug 15, 2024
10a1133
Rename variables
k4th Aug 16, 2024
e70ca11
Rename destroy endpoint methods to delete (#73)
k4th Aug 19, 2024
bbbf757
Update tests
k4th Aug 19, 2024
9a85954
Merge remote-tracking branch 'upstream/wip-v2' into add-tests
k4th Aug 19, 2024
4410f8c
Revert "Rename destroy endpoint methods to delete (#73)" (#74)
k4th Aug 19, 2024
6677db6
Update tests
k4th Aug 19, 2024
a5a7460
Add tests
k4th Aug 19, 2024
baab83d
Update tests
k4th Aug 19, 2024
4250ec3
Update tests
k4th Aug 19, 2024
a555f4b
replace destroy by delete
citin Aug 19, 2024
8758eca
Merge pull request #3 from citin/add-tests
k4th Aug 19, 2024
7d7de9e
Merge branch 'wip-v2' into add-tests
k4th Aug 19, 2024
776c62d
Add recordings
k4th Aug 19, 2024
fe61dae
fix rubocop linter
citin Aug 19, 2024
123457c
EPT-2950 Add tests (#75)
k4th Aug 19, 2024
028109c
Revert "EPT-2950 Add tests (#75)"
citin Aug 19, 2024
5dd203e
Merge pull request #77 from ePages-de/revert-75-add-tests
citin Aug 19, 2024
f40a769
Merge pull request #76 from citin/fix-linter
citin Aug 19, 2024
6a133eb
update docs, fix some errors
citin Aug 21, 2024
8341f7c
Merge pull request #80 from citin/improve-docs
citin Aug 21, 2024
b150767
EPT-2986 Add comments (#79)
k4th Aug 21, 2024
13c1056
EPT-2953 Add endpoints to upload images (#82)
k4th Aug 28, 2024
6dc1f65
adds services from authentication
citin Sep 3, 2024
e488f0d
[WIP] add tests
citin Sep 4, 2024
8c70b3f
fix dotenv for testing
citin Sep 6, 2024
922c1fd
Merge pull request #83 from citin/add-authentication-endpoints
citin Sep 6, 2024
fdb7ba5
Add customers endpoints (#84)
k4th Sep 9, 2024
dc83c3d
EPT-2966 Add carts endpoints (#85)
k4th Oct 3, 2024
1ee4d0e
Add shop endpoints (#87)
k4th Oct 7, 2024
3e7ccbf
Add webhooks endpoints (#86)
k4th Oct 7, 2024
5df83ed
Add endpoints for shop attributes and images (#89)
k4th Oct 15, 2024
3bdb42a
Add locations endpoint (#88)
kengallego Oct 15, 2024
7a93eda
Update README.md
citin Oct 21, 2024
a4e0b3f
Adds Storefront API endpoints (#91)
citin Oct 25, 2024
0bb065f
Fix params
unabris Oct 30, 2024
6a1796a
Rename things
unabris Oct 30, 2024
df4d042
Add product availability endpoints (#92)
k4th Oct 31, 2024
bafd0d6
Add products endpoint (#93)
kengallego Nov 5, 2024
87c8778
Update versions (#95)
k4th Jun 12, 2025
130b177
Upload image by url (#96)
k4th Jul 16, 2025
cf94613
Add variation endpoints (#97)
k4th Jul 22, 2025
7d41026
Fix update variation properties (#98)
kengallego Jul 23, 2025
d069da4
Add Search endpoint (#99)
kengallego Aug 14, 2025
2c2edd0
Add endpoint to upload external images to variations (#100)
unabris Sep 30, 2025
240c3dc
Upgrade faraday version (#102)
k4th Feb 24, 2026
bd421d8
Fix no pagination (#103)
k4th Jul 15, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .env.template → .env.development.template
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
CLIENT_ID=""
CLIENT_SECRET=""
SHOP_URL=""
10 changes: 10 additions & 0 deletions .env.test.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
API_URL=""

CLIENT_ID=""
CLIENT_SECRET=""
REFRESH_TOKEN=""

COCKPIT_USER_ID=""
COCKPIT_USER_NAME=""
COCKPIT_USER_EMAIL=""
COCKPIT_USER_PASSWORD=""
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
.rspec_status

# Environment variables
.env
.env*
!.env.*.template

# Apple file system
.DS_Store
37 changes: 24 additions & 13 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,35 +1,46 @@
require:
- rubocop-ordered_methods
- rubocop-rspec
- rubocop-rails

# Enable all new cops by default

AllCops:
Exclude:
- spec/**/*.rb
NewCops: enable
Exclude:
- bin/*
- spec/dummy/bin/*
- spec/dummy/db/schema.rb

Style/StringLiterals:
EnforcedStyle: double_quotes
# Disable not wanted cops

Metrics/AbcSize:
Enabled: false
Metrics/MethodLength:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/ClassLength:
Enabled: false
Style/Documentation:
Enabled: false
Metrics/BlockLength:
Enabled: false
Metrics/CyclomaticComplexity:
Enabled: false
Metrics/PerceivedComplexity:
Enabled: false

Layout/LineLength:
IgnoredPatterns: ['(\A|\s)#']

Style/AsciiComments:
Rails/ContentTag:
Enabled: false
Style/HashAsLastArrayItem:
Enabled: false
Naming/VariableNumber:
Enabled: false
Gemspec/DevelopmentDependencies:
Enabled: false

# Prefer to use brackets on symbol arrays

Style/SymbolArray:
EnforcedStyle: brackets

# Prefer to use always lambda literals (->)

Style/Lambda:
EnforcedStyle: literal
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.3.4
105 changes: 105 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Commands

```bash
# Install dependencies
bin/setup

# Run all tests
bundle exec rspec

# Run a single spec file
bundle exec rspec spec/beyond_api/services/product_management/product_spec.rb

# Run a single example
bundle exec rspec spec/beyond_api/services/product_management/product_spec.rb -e "returns all products"

# Lint
bundle exec rubocop

# Auto-fix lint issues
bundle exec rubocop -a

# Generate docs
bundle exec rake yard

# Interactive console (uses .env.development)
bin/console

# Install gem locally
bundle exec rake install
```

## Environment Setup

Copy `.env.test.template` to `.env.test` and fill in credentials before running tests. Copy `.env.development.template` to `.env.development` for the console.

Required env vars: `API_URL`, `CLIENT_ID`, `CLIENT_SECRET`, `REFRESH_TOKEN`.

## Architecture

This is a Ruby gem wrapping the [ePages Beyond API](https://developer.epages.com/beyond-docs/). It uses **Faraday** for HTTP and **Zeitwerk** for autoloading.

### Namespace Structure

Services live under `lib/beyond_api/services/` and are exposed as `BeyondApi::<Namespace>::<Resource>`:

- `BeyondApi::Authentication::Token` — OAuth token generation (client credentials, authorization code, refresh token)
- `BeyondApi::Authentication::Signer` — request signing
- `BeyondApi::ProductManagement::Product` — products CRUD
- `BeyondApi::ProductManagement::Category` — product categories
- `BeyondApi::ProductManagement::Image` / `VariationImage` / `Variation` — product media and variations
- `BeyondApi::ProductView::Category` — storefront product view
- `BeyondApi::Checkout::ShippingZone` / `Cart` — checkout flows
- `BeyondApi::Shop::Shop` / `Address` — shop configuration
- `BeyondApi::Storefront::ScriptTag` — storefront scripting
- `BeyondApi::Webhook::Subscription` — webhook management
- `BeyondApi::Customer` — customer records

### Request/Response Flow

1. Each service class inherits from `BeyondApi::BaseService`.
2. `BaseService` includes `Concerns::Connection` (HTTP methods: `get`, `post`, `put`, `patch`, `delete`, `upload_file`, `upload_files`) and `Concerns::Pagination`.
3. Request bodies are **camelized** before sending via `Utils.camelize_keys`. `Authentication::Token` disables this (`@camelize_keys = false`).
4. Responses are parsed by `BeyondApi::Response`, which **snake_cases** all keys and converts them to symbols. Leading underscores are stripped (e.g., `_links` → `:links`).
5. Failed responses raise `BeyondApi::Error`; Faraday connection errors raise `BeyondApi::FaradayError`.

### Pagination

- `fetch_all_pages(url, params)` — when `params[:paginated] == false`, uses `AllPagesHandler` to automatically fetch and merge all pages; otherwise returns the single paginated response.
- `AllPagesHandler` iterates pages using `all_pagination_size` (default 200) and merges results under the embedded resource key.

### Authentication

`Authentication::Token` uses `:basic` authorization (client_id/client_secret) rather than `:bearer`. All other services use bearer token auth. The Faraday connection is lazily built and memoized in `@agent`.

### Configuration

```ruby
BeyondApi.setup do |config|
config.client_id = 'your_client_id'
config.client_secret = 'your_client_secret'
config.timeout = 5 # seconds
config.open_timeout = 2 # seconds
config.log_level = :info
config.log_bodies = false
config.log_headers = false
config.all_pagination_size = 200
end
```

### Testing

Tests use **RSpec** with **VCR** cassettes (`spec/vcr_cassettes/`) to record and replay HTTP interactions. VCR matches on `[:method, :uri, :body]` and filters sensitive data. **FactoryBot** factories are in `spec/factories/`. The helper `beyond_access_token` in `spec_helper.rb` fetches a live token via `client_credentials`.

To record new cassettes, run with real credentials; existing cassettes are replayed without network access.

### Code Style

RuboCop is configured in `.rubocop.yml` with `rubocop-rails`. Notable conventions:
- Symbol arrays use bracket style: `[:foo, :bar]`
- Lambda literals use `->` syntax
- Metric cops (AbcSize, MethodLength, ClassLength, BlockLength) are disabled
Loading