campus_ivy 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/AGENTS.md +58 -0
- data/CHANGELOG.md +14 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +98 -0
- data/Rakefile +8 -0
- data/lib/campus_ivy/client.rb +34 -0
- data/lib/campus_ivy/configuration.rb +19 -0
- data/lib/campus_ivy/connection.rb +24 -0
- data/lib/campus_ivy/object.rb +42 -0
- data/lib/campus_ivy/resources/.keep +0 -0
- data/lib/campus_ivy/resources/account.rb +76 -0
- data/lib/campus_ivy/version.rb +5 -0
- data/lib/campus_ivy.rb +23 -0
- data/sig/campus_ivy.rbs +4 -0
- metadata +158 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: f4cb4e26d5923cc56a29d4cd0b70289004d39299720baf5207345674ca7392bf
|
|
4
|
+
data.tar.gz: ba09678a33c23594f4612665b004272ab90d8d3ee0a58c94478be8188963e95c
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 0133ba499fee8a4ba7261ebdf445d694f19d9fd35df9fd5fdbbdfbbcc6c1f71ee155d1f2a2368f892a3bfaa30167bad1e803521f3150a045b9bf1b99968a31f2
|
|
7
|
+
data.tar.gz: ed185bb83060c9311e66e53ad0baaf5dce2673c16c5d09560ff793379fc860584de6c9c88e0dadd6d49467164859c0c8a2169fff88436fa55f0549458ef9b3e6
|
data/AGENTS.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# AGENTS.md - System Context & Architecture Spec for campus_ivy
|
|
2
|
+
|
|
3
|
+
## 1. Project Identity
|
|
4
|
+
**Name:** campus_ivy
|
|
5
|
+
**Type:** Ruby Gem (API Wrapper)
|
|
6
|
+
**Purpose:** Provide a clean, idiomatic Ruby interface for the Campus Management API.
|
|
7
|
+
|
|
8
|
+
## 2. Tech Stack Requirements
|
|
9
|
+
- **Language:** Ruby 3.2+
|
|
10
|
+
- **HTTP Client:** `faraday` (Strict requirement: do not use Net::HTTP directly).
|
|
11
|
+
- **JSON Parsing:** `faraday_middleware` or `faraday` v2 JSON adapter.
|
|
12
|
+
- **Testing:** `rspec`, `webmock`, `vcr`.
|
|
13
|
+
- **Linting:** `rubocop`.
|
|
14
|
+
|
|
15
|
+
## 3. Testing Requirements
|
|
16
|
+
- **Verification:** The agent must run relevant tests for any work performed.
|
|
17
|
+
- **Coverage:** New modules or functions must include comprehensive test suites (specs).
|
|
18
|
+
- **Strategy:** Prefer integration testing with VCR over extensive unit mocking for API interactions.
|
|
19
|
+
|
|
20
|
+
## 4. Mandatory Architecture Patterns
|
|
21
|
+
The agent must implement the following four patterns without deviation:
|
|
22
|
+
|
|
23
|
+
### A. The Client & Resource Pattern
|
|
24
|
+
* **Entry Point:** `CampusIvy::Client` must be the primary interface.
|
|
25
|
+
* **Isolation:** Do not crowd the Client class with API methods.
|
|
26
|
+
* **Implementation:**
|
|
27
|
+
* Create a `lib/campus_ivy/resources/` directory.
|
|
28
|
+
* The `Client` class initializes these resource classes (e.g., `def students; Resources::Students.new(self); end`).
|
|
29
|
+
* Usage must look like: `client.students.find('id')`.
|
|
30
|
+
|
|
31
|
+
### B. The Middleware Pattern
|
|
32
|
+
* **Requirement:** Use a custom Faraday connection stack in a dedicated `Connection` module.
|
|
33
|
+
* **Handling:**
|
|
34
|
+
* Automatically handle Authentication headers.
|
|
35
|
+
* Automatically parse JSON requests and responses.
|
|
36
|
+
* **Crucial:** Use middleware to intercept non-200 status codes and raise specific exceptions (`CampusIvy::Error`, `CampusIvy::RateLimitError`) *before* returning data.
|
|
37
|
+
|
|
38
|
+
### C. The Entity/Object Pattern
|
|
39
|
+
* **Requirement:** Never return raw Hashes to the user.
|
|
40
|
+
* **Implementation:**
|
|
41
|
+
* Wrap all API responses in a lightweight object (e.g., `CampusIvy::Object`).
|
|
42
|
+
* Allow dot-notation access (e.g., `student.first_name`, NOT `student['first_name']`).
|
|
43
|
+
* Use `OpenStruct` or a custom `Data` class for immutability.
|
|
44
|
+
|
|
45
|
+
### D. The Configuration Pattern
|
|
46
|
+
* **Requirement:** Support both global module configuration and instance-level overrides.
|
|
47
|
+
* **Snippet Reference:**
|
|
48
|
+
```ruby
|
|
49
|
+
CampusIvy.configure { |c| c.api_key = 'xyz' }
|
|
50
|
+
# VS
|
|
51
|
+
client = CampusIvy::Client.new(api_key: 'abc')
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## 5. Coding Standards (Rubocop)
|
|
55
|
+
- Use keyword arguments for all optional parameters.
|
|
56
|
+
- Keep methods under 15 lines.
|
|
57
|
+
- No `puts` statements in library code (use a Logger if necessary).
|
|
58
|
+
- RSpec: Use `let`, `expect`, and `vcr` cassettes. Do not mock internal implementation details; mock the HTTP network layer.
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [0.1.0] - 2025-12-16
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
- **Account Resource:** Implemented full support for the Account module (`CampusIvy::Resources::Account`).
|
|
7
|
+
- Added `token` method for full authentication.
|
|
8
|
+
- Added `token_credentials` for username/password authentication.
|
|
9
|
+
- Added `token_key` for client key authentication.
|
|
10
|
+
- Added `logout` method.
|
|
11
|
+
- **Typing:** Integrated `sorbet-runtime` for strict type checking on all new methods.
|
|
12
|
+
- **Client:** Added `account` accessor to the main `CampusIvy::Client`.
|
|
13
|
+
- **Configuration:** Added ability to override `base_url` directly in configuration.
|
|
14
|
+
- **Testing:** Added comprehensive RSpec tests for the Account resource and fixed Client spec configuration.
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 marcus.salinas
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# CampusIvy
|
|
2
|
+
|
|
3
|
+
A clean, idiomatic Ruby interface for interact with the Campus Management API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bundle add campus_ivy
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
gem install campus_ivy
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Configuration
|
|
22
|
+
|
|
23
|
+
You can configure the client globally or per instance.
|
|
24
|
+
|
|
25
|
+
**Global Configuration:**
|
|
26
|
+
|
|
27
|
+
```ruby
|
|
28
|
+
CampusIvy.configure do |config|
|
|
29
|
+
config.api_key = 'your_api_key'
|
|
30
|
+
# Optional: Set sandbox to true (defaults to false)
|
|
31
|
+
config.sandbox = true
|
|
32
|
+
end
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Environment Variables:**
|
|
36
|
+
|
|
37
|
+
You can also set the sandbox mode via an environment variable:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
export CAMPUS_IVY_USE_SANDBOX=true
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Instance Configuration:**
|
|
44
|
+
|
|
45
|
+
```ruby
|
|
46
|
+
client = CampusIvy::Client.new(api_key: 'your_api_key')
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Account Resource
|
|
50
|
+
|
|
51
|
+
The `Account` resource allows you to manage authentication and sessions.
|
|
52
|
+
|
|
53
|
+
```ruby
|
|
54
|
+
client = CampusIvy::Client.new
|
|
55
|
+
|
|
56
|
+
# Generate an Access Token
|
|
57
|
+
token_response = client.account.token(
|
|
58
|
+
institution_id: 12345,
|
|
59
|
+
client_key: 'your_client_key',
|
|
60
|
+
username: 'username',
|
|
61
|
+
password: 'password'
|
|
62
|
+
)
|
|
63
|
+
puts token_response.access_token
|
|
64
|
+
|
|
65
|
+
# Generate Access Token with Credentials only
|
|
66
|
+
client.account.token_credentials(
|
|
67
|
+
institution_id: 12345,
|
|
68
|
+
username: 'username',
|
|
69
|
+
password: 'password'
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Generate Access Token with Client Key only
|
|
73
|
+
client.account.token_key(
|
|
74
|
+
institution_id: 12345,
|
|
75
|
+
client_key: 'your_client_key'
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
# Logout
|
|
79
|
+
client.account.logout
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Development
|
|
83
|
+
|
|
84
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
85
|
+
|
|
86
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
87
|
+
|
|
88
|
+
## Contributing
|
|
89
|
+
|
|
90
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jippylong12/campus_ivy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/jippylong12/campus_ivy/blob/main/CODE_OF_CONDUCT.md).
|
|
91
|
+
|
|
92
|
+
## License
|
|
93
|
+
|
|
94
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
95
|
+
|
|
96
|
+
## Code of Conduct
|
|
97
|
+
|
|
98
|
+
Everyone interacting in the CampusIvy project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/jippylong12/campus_ivy/blob/main/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'configuration'
|
|
4
|
+
require_relative 'connection'
|
|
5
|
+
|
|
6
|
+
module CampusIvy
|
|
7
|
+
class Client
|
|
8
|
+
extend T::Sig
|
|
9
|
+
include CampusIvy::Connection
|
|
10
|
+
|
|
11
|
+
attr_reader :config
|
|
12
|
+
|
|
13
|
+
def initialize(options = {})
|
|
14
|
+
# Initialize with global config values, overridden by options
|
|
15
|
+
@config = CampusIvy::Configuration.new
|
|
16
|
+
|
|
17
|
+
# Copy global configuration
|
|
18
|
+
CampusIvy.configuration.instance_variables.each do |var|
|
|
19
|
+
val = CampusIvy.configuration.instance_variable_get(var)
|
|
20
|
+
@config.instance_variable_set(var, val)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
# Override with instance options
|
|
24
|
+
options.each do |key, value|
|
|
25
|
+
@config.send("#{key}=", value) if @config.respond_to?("#{key}=")
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
sig { returns(CampusIvy::Resources::Account) }
|
|
30
|
+
def account
|
|
31
|
+
Resources::Account.new(self)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CampusIvy
|
|
4
|
+
class Configuration
|
|
5
|
+
attr_accessor :api_key, :base_url
|
|
6
|
+
attr_reader :sandbox
|
|
7
|
+
|
|
8
|
+
def initialize
|
|
9
|
+
@api_key = nil
|
|
10
|
+
@sandbox = ENV['CAMPUS_IVY_USE_SANDBOX'] == 'true'
|
|
11
|
+
@base_url = @sandbox ? 'https://apisandbox.campusivy.com/Apis/CampusIvy.API/api' : 'https://api.campusivy.com/v1'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def sandbox=(value)
|
|
15
|
+
@sandbox = value
|
|
16
|
+
@base_url = @sandbox ? 'https://apisandbox.campusivy.com/Apis/CampusIvy.API/api' : 'https://api.campusivy.com/v1'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'faraday'
|
|
4
|
+
require 'json'
|
|
5
|
+
|
|
6
|
+
module CampusIvy
|
|
7
|
+
module Connection
|
|
8
|
+
def connection
|
|
9
|
+
@connection ||= Faraday.new(url: config.base_url) do |conn|
|
|
10
|
+
conn.request :json
|
|
11
|
+
|
|
12
|
+
# Authentication header
|
|
13
|
+
conn.request :authorization, :Bearer, config.api_key if config.api_key
|
|
14
|
+
|
|
15
|
+
conn.response :json, content_type: /\bjson$/
|
|
16
|
+
|
|
17
|
+
# Custom middleware for handling errors could go here
|
|
18
|
+
# conn.use CampusIvy::Middleware::ErrorHandler
|
|
19
|
+
|
|
20
|
+
conn.adapter Faraday.default_adapter
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'ostruct'
|
|
4
|
+
|
|
5
|
+
module CampusIvy
|
|
6
|
+
class Object < OpenStruct
|
|
7
|
+
def initialize(attributes = {})
|
|
8
|
+
super(
|
|
9
|
+
attributes.transform_values do |value|
|
|
10
|
+
if value.is_a?(Hash)
|
|
11
|
+
CampusIvy::Object.new(value)
|
|
12
|
+
elsif value.is_a?(Array)
|
|
13
|
+
value.map { |v| v.is_a?(Hash) ? CampusIvy::Object.new(v) : v }
|
|
14
|
+
else
|
|
15
|
+
value
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def method_missing(method, *args, &block)
|
|
22
|
+
if encoding_aware? && method.to_s.end_with?('=')
|
|
23
|
+
super
|
|
24
|
+
else
|
|
25
|
+
value = super
|
|
26
|
+
if value.is_a?(Hash)
|
|
27
|
+
CampusIvy::Object.new(value)
|
|
28
|
+
elsif value.is_a?(Array)
|
|
29
|
+
value.map { |v| v.is_a?(Hash) ? CampusIvy::Object.new(v) : v }
|
|
30
|
+
else
|
|
31
|
+
value
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def encoding_aware?
|
|
39
|
+
defined?(::Encoding)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
File without changes
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module CampusIvy
|
|
4
|
+
module Resources
|
|
5
|
+
class Account
|
|
6
|
+
extend T::Sig
|
|
7
|
+
|
|
8
|
+
sig { params(client: CampusIvy::Client).void }
|
|
9
|
+
def initialize(client)
|
|
10
|
+
@client = client
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
sig do
|
|
14
|
+
params(
|
|
15
|
+
institution_id: Integer,
|
|
16
|
+
client_key: String,
|
|
17
|
+
username: String,
|
|
18
|
+
password: String
|
|
19
|
+
).returns(CampusIvy::Object)
|
|
20
|
+
end
|
|
21
|
+
def token(institution_id:, client_key:, username:, password:)
|
|
22
|
+
response = @client.connection.post('account/token') do |req|
|
|
23
|
+
req.body = {
|
|
24
|
+
institutionId: institution_id,
|
|
25
|
+
clientKey: client_key,
|
|
26
|
+
userName: username,
|
|
27
|
+
password: password
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
CampusIvy::Object.new(response.body)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
sig do
|
|
34
|
+
params(
|
|
35
|
+
institution_id: Integer,
|
|
36
|
+
username: String,
|
|
37
|
+
password: String
|
|
38
|
+
).returns(CampusIvy::Object)
|
|
39
|
+
end
|
|
40
|
+
def token_credentials(institution_id:, username:, password:)
|
|
41
|
+
response = @client.connection.post('account/token/credentials') do |req|
|
|
42
|
+
req.body = {
|
|
43
|
+
institutionId: institution_id,
|
|
44
|
+
userName: username,
|
|
45
|
+
password: password
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
CampusIvy::Object.new(response.body)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
sig do
|
|
52
|
+
params(
|
|
53
|
+
institution_id: Integer,
|
|
54
|
+
client_key: String
|
|
55
|
+
).returns(CampusIvy::Object)
|
|
56
|
+
end
|
|
57
|
+
def token_key(institution_id:, client_key:)
|
|
58
|
+
response = @client.connection.post('account/token/key') do |req|
|
|
59
|
+
req.body = {
|
|
60
|
+
institutionId: institution_id,
|
|
61
|
+
clientKey: client_key
|
|
62
|
+
}
|
|
63
|
+
end
|
|
64
|
+
CampusIvy::Object.new(response.body)
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
sig { returns(T.nilable(CampusIvy::Object)) }
|
|
68
|
+
def logout
|
|
69
|
+
response = @client.connection.post('account/logout')
|
|
70
|
+
return nil if response.body.nil? || response.body.empty?
|
|
71
|
+
|
|
72
|
+
CampusIvy::Object.new(response.body)
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
data/lib/campus_ivy.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'campus_ivy/version'
|
|
4
|
+
require 'sorbet-runtime'
|
|
5
|
+
require_relative 'campus_ivy/configuration'
|
|
6
|
+
require_relative 'campus_ivy/object'
|
|
7
|
+
require_relative 'campus_ivy/resources/account'
|
|
8
|
+
require_relative 'campus_ivy/client'
|
|
9
|
+
|
|
10
|
+
module CampusIvy
|
|
11
|
+
class Error < StandardError; end
|
|
12
|
+
class RateLimitError < Error; end
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
def configuration
|
|
16
|
+
@configuration ||= Configuration.new
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def configure
|
|
20
|
+
yield(configuration)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/sig/campus_ivy.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: campus_ivy
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- marcus.salinas
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: faraday
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - "~>"
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '2.0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - "~>"
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '2.0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: sorbet-runtime
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: rake
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '13.0'
|
|
47
|
+
type: :development
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '13.0'
|
|
54
|
+
- !ruby/object:Gem::Dependency
|
|
55
|
+
name: rspec
|
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - "~>"
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '3.0'
|
|
61
|
+
type: :development
|
|
62
|
+
prerelease: false
|
|
63
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
64
|
+
requirements:
|
|
65
|
+
- - "~>"
|
|
66
|
+
- !ruby/object:Gem::Version
|
|
67
|
+
version: '3.0'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: rubocop
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - ">="
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0'
|
|
82
|
+
- !ruby/object:Gem::Dependency
|
|
83
|
+
name: vcr
|
|
84
|
+
requirement: !ruby/object:Gem::Requirement
|
|
85
|
+
requirements:
|
|
86
|
+
- - ">="
|
|
87
|
+
- !ruby/object:Gem::Version
|
|
88
|
+
version: '0'
|
|
89
|
+
type: :development
|
|
90
|
+
prerelease: false
|
|
91
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
+
requirements:
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: webmock
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '0'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
110
|
+
description: A clean, idiomatic Ruby interface for interacting with the Campus Management
|
|
111
|
+
API.
|
|
112
|
+
email:
|
|
113
|
+
- 12.marcus.salinas@gmail.com
|
|
114
|
+
executables: []
|
|
115
|
+
extensions: []
|
|
116
|
+
extra_rdoc_files: []
|
|
117
|
+
files:
|
|
118
|
+
- AGENTS.md
|
|
119
|
+
- CHANGELOG.md
|
|
120
|
+
- CODE_OF_CONDUCT.md
|
|
121
|
+
- LICENSE.txt
|
|
122
|
+
- README.md
|
|
123
|
+
- Rakefile
|
|
124
|
+
- lib/campus_ivy.rb
|
|
125
|
+
- lib/campus_ivy/client.rb
|
|
126
|
+
- lib/campus_ivy/configuration.rb
|
|
127
|
+
- lib/campus_ivy/connection.rb
|
|
128
|
+
- lib/campus_ivy/object.rb
|
|
129
|
+
- lib/campus_ivy/resources/.keep
|
|
130
|
+
- lib/campus_ivy/resources/account.rb
|
|
131
|
+
- lib/campus_ivy/version.rb
|
|
132
|
+
- sig/campus_ivy.rbs
|
|
133
|
+
homepage: https://github.com/jippylong12/campus_ivy
|
|
134
|
+
licenses:
|
|
135
|
+
- MIT
|
|
136
|
+
metadata:
|
|
137
|
+
allowed_push_host: https://rubygems.org
|
|
138
|
+
homepage_uri: https://github.com/jippylong12/campus_ivy
|
|
139
|
+
source_code_uri: https://github.com/jippylong12/campus_ivy
|
|
140
|
+
changelog_uri: https://github.com/jippylong12/campus_ivy/blob/main/CHANGELOG.md
|
|
141
|
+
rdoc_options: []
|
|
142
|
+
require_paths:
|
|
143
|
+
- lib
|
|
144
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
145
|
+
requirements:
|
|
146
|
+
- - ">="
|
|
147
|
+
- !ruby/object:Gem::Version
|
|
148
|
+
version: 3.2.0
|
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
|
+
requirements:
|
|
151
|
+
- - ">="
|
|
152
|
+
- !ruby/object:Gem::Version
|
|
153
|
+
version: '0'
|
|
154
|
+
requirements: []
|
|
155
|
+
rubygems_version: 3.7.2
|
|
156
|
+
specification_version: 4
|
|
157
|
+
summary: Ruby wrapper for the Campus Management API.
|
|
158
|
+
test_files: []
|