Skip to content

KRED-2900 Add POST /split_rules#56

Merged
syauqimekari merged 2 commits intomainfrom
KRED-2900
Oct 8, 2025
Merged

KRED-2900 Add POST /split_rules#56
syauqimekari merged 2 commits intomainfrom
KRED-2900

Conversation

@syauqimekari
Copy link
Copy Markdown
Contributor

Add SplitRule API Support

🎯 Overview

This PR adds comprehensive support for Xendit's Split Rule API functionality to the xendit_api gem, enabling developers to create and manage payment split rules programmatically.

📝 Changes Made

✨ New Features

  • Split Rule API Integration: Added complete Split Rule API client functionality
  • Split Rule Model: Created model class for handling Split Rule data structures
  • Client Integration: Integrated Split Rule API into the main Xendit client

📁 Files Added

  • lib/xendit_api/api/split_rule.rb - Split Rule API client implementation
  • lib/xendit_api/model/split_rule.rb - Split Rule model class
  • spec/xendit_api/api/split_rule_spec.rb - Comprehensive API tests (7 test cases)
  • spec/xendit_api/model/split_rule_spec.rb - Comprehensive model tests (13 test cases)

🔧 Files Modified

  • lib/xendit_api/client.rb - Added Split Rule API integration and client method

🚀 API Features

Split Rule API (XenditApi::Api::SplitRule)

  • create(params): Create new split rules with routing configurations
  • PATH constant: Defines the API endpoint (/split_rules)
  • Header management: Automatic Path-Group header handling
  • Error handling: Proper error propagation from HTTP client

Split Rule Model (XenditApi::Model::SplitRule)

  • Attributes: id, name, description, created, updated, routes
  • Flexible initialization: Support for hash attributes with symbol/string keys
  • Base class inheritance: Leverages existing model infrastructure
  • Route data handling: Supports complex nested route structures

🧪 Testing Coverage

  • 20 total test cases with 100% code coverage
  • API tests: 7 comprehensive test cases covering all functionality
  • Model tests: 13 test cases covering all initialization scenarios and edge cases
  • Error handling: Tests for proper error propagation
  • Data validation: Tests for attribute assignment and complex data structures

Test Coverage Details

API Tests:

  • PATH constant verification
  • Inheritance validation
  • Create method functionality
  • Header management (Path-Group)
  • Parameter passing
  • Error propagation
  • Constructor validation

Model Tests:

  • Inheritance from Base class
  • All attribute accessors
  • Multiple initialization scenarios (hash, string keys, mixed keys, partial, empty, nil)
  • Unknown attribute handling
  • Individual attribute assignment
  • Complex nested route data structures

🔍 Technical Implementation

Architecture

  • Follows existing gem patterns and conventions
  • Inherits from XenditApi::Api::Base for consistent API client behavior
  • Inherits from XenditApi::Model::Base for consistent model behavior
  • Proper separation of concerns between API client and data model

Error Handling

  • Maintains existing error handling patterns
  • Propagates HTTP client errors appropriately
  • Handles malformed responses gracefully

Data Handling

  • Supports flexible attribute assignment
  • Handles both symbol and string keys
  • Ignores unknown attributes safely
  • Supports complex nested data structures for route configurations

✅ Quality Assurance

  • ✅ All tests passing (20/20)
  • ✅ 100% code coverage achieved
  • ✅ Follows existing code patterns and conventions
  • ✅ Comprehensive error handling
  • ✅ No breaking changes to existing functionality
  • ✅ Proper integration with existing client infrastructure

🎯 Impact

  • New functionality: Adds Split Rule API support without affecting existing features
  • Developer experience: Provides intuitive API for managing payment splits
  • Maintainability: Well-tested code with comprehensive test coverage
  • Consistency: Follows established patterns in the gem

📋 Checklist

  • API client implementation
  • Model class implementation
  • Client integration
  • Comprehensive test coverage
  • Error handling
  • Documentation
  • Code quality validation

Related Ticket: KRED-2900
API Documentation: Xendit Split Rule API

@syauqimekari syauqimekari merged commit f32d2ef into main Oct 8, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants