magic-admin 0.0.0 โ 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 +4 -4
- data/.github/ISSUE_TEMPLATE/bug_report.md +42 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +23 -0
- data/.github/ISSUE_TEMPLATE/question.md +23 -0
- data/.github/PULL_REQUEST_TEMPLATE.md +23 -0
- data/.gitignore +7 -0
- data/.rspec +6 -0
- data/.rubocop.yml +45 -0
- data/CHANGELOG.md +17 -0
- data/CONTRIBUTING.md +142 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +73 -0
- data/bin/magic-console +14 -0
- data/lib/magic-admin.rb +135 -0
- data/lib/magic-admin/config.rb +71 -0
- data/lib/magic-admin/errors.rb +98 -0
- data/lib/magic-admin/http/client.rb +136 -0
- data/lib/magic-admin/http/request.rb +89 -0
- data/lib/magic-admin/http/response.rb +95 -0
- data/lib/magic-admin/resource/token.rb +146 -0
- data/lib/magic-admin/resource/user.rb +130 -0
- data/lib/magic-admin/util.rb +61 -0
- data/lib/magic-admin/version.rb +5 -0
- data/magic-admin.gemspec +36 -0
- data/test/http/client_test.rb +79 -0
- data/test/http/request_test.rb +52 -0
- data/test/http/response_test.rb +192 -0
- data/test/magic_test.rb +124 -0
- data/test/resource/token_test.rb +187 -0
- data/test/resource/user_test.rb +98 -0
- data/test/spec_helper.rb +48 -0
- data/test/util_test.rb +42 -0
- metadata +140 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 623f1dec3237ad8a1e3e380c057426b518e477295b5bad40ec4736fee99e0ddb
|
4
|
+
data.tar.gz: ebc06d06cdf25d95bed3fede31f18c8b7b8e21246b5104ed137ec208af7b30fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a645a3964a5e3d34671993ddc49a75d7c76311457a2f86a612ac2a8b040faceebac65f42d4c1f28bf455a76cfa703a0f0c7211a8805e8abead99eb53c1a280
|
7
|
+
data.tar.gz: a8da9649524f9cb17d209b0e13c3c60d0b3fc14b5e541c90efb948cb3d5d6c18f3c2a97f34629e12988bb406168264f3aa5721835e7f57149b49e550dc9e0c19
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
name: Bug Report
|
3
|
+
about: Use this template to report a bug.
|
4
|
+
title: "[DESCRIPTIVE BUG NAME]"
|
5
|
+
labels: ๐ Bug Report, ๐ Needs Triage
|
6
|
+
---
|
7
|
+
|
8
|
+
### โ
Prerequisites
|
9
|
+
|
10
|
+
- [ ] Did you perform a cursory search of open issues? Is this bug already reported elsewhere?
|
11
|
+
- [ ] Are you running the latest SDK version?
|
12
|
+
- [ ] Are you reporting to the correct repository (`magic-admin-ruby`)?
|
13
|
+
|
14
|
+
### ๐ Description
|
15
|
+
|
16
|
+
[Description of the bug.]
|
17
|
+
|
18
|
+
### ๐งฉ Steps to Reproduce
|
19
|
+
|
20
|
+
1. [First Step]
|
21
|
+
2. [Second Step]
|
22
|
+
3. [and so on...]
|
23
|
+
|
24
|
+
### ๐ค Expected behavior
|
25
|
+
|
26
|
+
[What you expected to happen?]
|
27
|
+
|
28
|
+
### ๐ฎ Actual behavior
|
29
|
+
|
30
|
+
[What actually happened? Please include any error stack traces you encounter.]
|
31
|
+
|
32
|
+
### ๐ป Code Sample
|
33
|
+
|
34
|
+
[If possible, please provide a code repository, gist, code snippet or sample files to reproduce the issue.]
|
35
|
+
|
36
|
+
### ๐ Environment
|
37
|
+
|
38
|
+
| Software | Version(s) |
|
39
|
+
| ------------------- | ---------- |
|
40
|
+
| `magic-admin-ruby` | |
|
41
|
+
| `ruby` | |
|
42
|
+
| Operating System | |
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
name: Feature Request
|
3
|
+
about: Use this template to request a new feature.
|
4
|
+
title: "[DESCRIPTIVE FEATURE NAME]"
|
5
|
+
labels: โจFeature Request
|
6
|
+
---
|
7
|
+
|
8
|
+
### โ
Prerequisites
|
9
|
+
|
10
|
+
- [ ] Did you perform a cursory search of open issues? Is this feature already requested elsewhere?
|
11
|
+
- [ ] Are you reporting to the correct repository (`magic-admin-ruby`)?
|
12
|
+
|
13
|
+
### โจ Feature Request
|
14
|
+
|
15
|
+
[Description of the feature.]
|
16
|
+
|
17
|
+
## ๐งฉ Context
|
18
|
+
|
19
|
+
[Explain any additional context or rationale for this feature. What are you trying to accomplish?]
|
20
|
+
|
21
|
+
## ๐ป Examples
|
22
|
+
|
23
|
+
[Do you have any example(s) for the requested feature? If so, describe/demonstrate your example(s) here.]
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
name: Question
|
3
|
+
about: Use this template to request help or ask a question.
|
4
|
+
title: "[WHAT'S YOUR QUESTION?]"
|
5
|
+
labels: โQuestion
|
6
|
+
---
|
7
|
+
|
8
|
+
### โ
Prerequisites
|
9
|
+
|
10
|
+
- [ ] Did you perform a cursory search of open issues? Is this question already asked elsewhere?
|
11
|
+
- [ ] Are you reporting to the correct repository (`magic-admin-ruby`)?
|
12
|
+
|
13
|
+
### โ Question
|
14
|
+
|
15
|
+
[Ask your question here, please be as detailed as possible!]
|
16
|
+
|
17
|
+
### ๐ Environment
|
18
|
+
|
19
|
+
| Software | Version(s) |
|
20
|
+
| ------------------- | ---------- |
|
21
|
+
| `magic-admin-ruby` | |
|
22
|
+
| `ruby` | |
|
23
|
+
| Operating System | |
|
@@ -0,0 +1,23 @@
|
|
1
|
+
### ๐ฆ Pull Request
|
2
|
+
|
3
|
+
[Provide a general summary of the pull request here.]
|
4
|
+
|
5
|
+
### ๐ Versioning
|
6
|
+
|
7
|
+
(Check _one!_)
|
8
|
+
|
9
|
+
- [ ] Patch: Bug Fix?
|
10
|
+
- [ ] Minor: New Feature?
|
11
|
+
- [ ] Major: Breaking Change?
|
12
|
+
|
13
|
+
### โ
Fixed Issues
|
14
|
+
|
15
|
+
- [List any fixed issues here like: Fixes #XXXX]
|
16
|
+
|
17
|
+
### ๐จ Test instructions
|
18
|
+
|
19
|
+
[Describe any additional context required to test the PR/feature/bug fix.]
|
20
|
+
|
21
|
+
### โ ๏ธ Update `CHANGELOG.md`
|
22
|
+
|
23
|
+
- [ ] I have updated the `Upcoming Changes` section of `CHANGELOG.md` with context related to this Pull Request.
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
Layout/CaseIndentation:
|
2
|
+
EnforcedStyle: end
|
3
|
+
|
4
|
+
Layout/FirstArrayElementIndentation:
|
5
|
+
EnforcedStyle: consistent
|
6
|
+
|
7
|
+
Layout/FirstHashElementIndentation:
|
8
|
+
EnforcedStyle: consistent
|
9
|
+
|
10
|
+
Metrics/MethodLength:
|
11
|
+
Max: 15
|
12
|
+
|
13
|
+
Metrics/ModuleLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/FrozenStringLiteralComment:
|
17
|
+
EnforcedStyle: always
|
18
|
+
|
19
|
+
Style/HashEachMethods:
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
Style/HashTransformKeys:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Style/HashTransformValues:
|
26
|
+
Enabled: true
|
27
|
+
|
28
|
+
Style/NumericPredicate:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/StringLiterals:
|
32
|
+
EnforcedStyle: double_quotes
|
33
|
+
|
34
|
+
Metrics/BlockLength:
|
35
|
+
Exclude:
|
36
|
+
- "test/**/*.rb"
|
37
|
+
|
38
|
+
Naming/FileName:
|
39
|
+
Exclude:
|
40
|
+
- "lib/magic-admin.rb"
|
41
|
+
|
42
|
+
Style/Documentation:
|
43
|
+
Exclude:
|
44
|
+
- "lib/magic-admin/config.rb"
|
45
|
+
- "lib/magic-admin/util.rb"
|
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
# Contributing
|
2
|
+
|
3
|
+
When contributing to this repository, please first discuss the change you wish to make via an **issue**. This can be a feature request or a bug report. After a maintainer has triaged your issue, you are welcome to collaborate on a pull request. If your change is small or uncomplicated, you are welcome to open an issue and pull request simultaneously.
|
4
|
+
|
5
|
+
Please note we have a **code of conduct**, please follow it in all your interactions with the project.
|
6
|
+
|
7
|
+
## Setting up for Local Development
|
8
|
+
|
9
|
+
1. Fork this repostiory.
|
10
|
+
2. Clone your fork.
|
11
|
+
3. Create a new branch in your local repository with the following pattern:
|
12
|
+
|
13
|
+
- For bug fixes: `bug/#[issue_number]/[descriptive_bug_name]`
|
14
|
+
- For features: `feature/#[issue_number]/[descriptive_feature_name]`
|
15
|
+
- For chores/the rest: `chore/[descriptive_chore_name]`
|
16
|
+
|
17
|
+
## Opening a Pull Request
|
18
|
+
|
19
|
+
1. Update the **`Upcoming Changes`** section of [`CHANGELOG.md`](./CHANGELOG.md) with your fixes, changes, or additions. A maintainer will label your changes with a version number and release date once they are published.
|
20
|
+
2. Open a pull request from your fork/branch to the upstream `master` branch of _this_ repository.
|
21
|
+
3. A maintainer will review your code changes and offer feedback or suggestions if necessary. Once your changes are approved, a maintainer will merge the pull request for you and publish a release.
|
22
|
+
|
23
|
+
## Contributor Covenant Code of Conduct
|
24
|
+
|
25
|
+
### Our Pledge
|
26
|
+
|
27
|
+
We as members, contributors, and leaders pledge to make participation in our
|
28
|
+
community a harassment-free experience for everyone, regardless of age, body
|
29
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
30
|
+
identity and expression, level of experience, education, socio-economic status,
|
31
|
+
nationality, personal appearance, race, religion, or sexual identity
|
32
|
+
and orientation.
|
33
|
+
|
34
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
35
|
+
diverse, inclusive, and healthy community.
|
36
|
+
|
37
|
+
### Our Standards
|
38
|
+
|
39
|
+
Examples of behavior that contributes to a positive environment for our
|
40
|
+
community include:
|
41
|
+
|
42
|
+
- Demonstrating empathy and kindness toward other people
|
43
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
44
|
+
- Giving and gracefully accepting constructive feedback
|
45
|
+
- Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
46
|
+
- Focusing on what is best not just for us as individuals, but for the overall community
|
47
|
+
|
48
|
+
Examples of unacceptable behavior include:
|
49
|
+
|
50
|
+
- The use of sexualized language or imagery, and sexual attention or advances of any kind
|
51
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
52
|
+
- Public or private harassment
|
53
|
+
- Publishing others' private information, such as a physical or email address, without their explicit permission
|
54
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
55
|
+
|
56
|
+
### Enforcement Responsibilities
|
57
|
+
|
58
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
59
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
60
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
61
|
+
or harmful.
|
62
|
+
|
63
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
64
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
65
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
66
|
+
decisions when appropriate.
|
67
|
+
|
68
|
+
### Scope
|
69
|
+
|
70
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
71
|
+
an individual is officially representing the community in public spaces.
|
72
|
+
Examples of representing our community include using an official e-mail address,
|
73
|
+
posting via an official social media account, or acting as an appointed
|
74
|
+
representative at an online or offline event.
|
75
|
+
|
76
|
+
### Enforcement
|
77
|
+
|
78
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
79
|
+
reported to the community leaders responsible for enforcement at [support@magic.link](mailto:support@magic.link).
|
80
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
81
|
+
|
82
|
+
All community leaders are obligated to respect the privacy and security of the
|
83
|
+
reporter of any incident.
|
84
|
+
|
85
|
+
### Enforcement Guidelines
|
86
|
+
|
87
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
88
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
89
|
+
|
90
|
+
#### 1. Correction
|
91
|
+
|
92
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
93
|
+
unprofessional or unwelcome in the community.
|
94
|
+
|
95
|
+
**Consequence**: A private, written warning from community leaders, providing
|
96
|
+
clarity around the nature of the violation and an explanation of why the
|
97
|
+
behavior was inappropriate. A public apology may be requested.
|
98
|
+
|
99
|
+
#### 2. Warning
|
100
|
+
|
101
|
+
**Community Impact**: A violation through a single incident or series
|
102
|
+
of actions.
|
103
|
+
|
104
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
105
|
+
interaction with the people involved, including unsolicited interaction with
|
106
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
107
|
+
includes avoiding interactions in community spaces as well as external channels
|
108
|
+
like social media. Violating these terms may lead to a temporary or
|
109
|
+
permanent ban.
|
110
|
+
|
111
|
+
#### 3. Temporary Ban
|
112
|
+
|
113
|
+
**Community Impact**: A serious violation of community standards, including
|
114
|
+
sustained inappropriate behavior.
|
115
|
+
|
116
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
117
|
+
communication with the community for a specified period of time. No public or
|
118
|
+
private interaction with the people involved, including unsolicited interaction
|
119
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
120
|
+
Violating these terms may lead to a permanent ban.
|
121
|
+
|
122
|
+
#### 4. Permanent Ban
|
123
|
+
|
124
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
125
|
+
standards, including sustained inappropriate behavior, harassment of an
|
126
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
127
|
+
|
128
|
+
**Consequence**: A permanent ban from any sort of public interaction within
|
129
|
+
the community.
|
130
|
+
|
131
|
+
### Attribution
|
132
|
+
|
133
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org),
|
134
|
+
version 2.0, available at
|
135
|
+
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
136
|
+
|
137
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
138
|
+
enforcement ladder](https://github.com/mozilla/diversity).
|
139
|
+
|
140
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
141
|
+
https://www.contributor-covenant.org/faq. Translations are available at
|
142
|
+
https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Magic Labs Inc.
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# Magic Admin Ruby SDK
|
2
|
+
|
3
|
+
The Magic Admin Ruby SDK provides convenient ways for developers to interact with Magic API endpoints and an array of utilities to handle [DID Token](https://docs.magic.link/tutorials/decentralized-id).
|
4
|
+
|
5
|
+
## Table of Contents
|
6
|
+
|
7
|
+
* [Documentation](#documentation)
|
8
|
+
* [Quick Start](#quick-start)
|
9
|
+
* [Changelog](#changelog)
|
10
|
+
* [License](#license)
|
11
|
+
|
12
|
+
## Documentation
|
13
|
+
See the [Magic doc](https://docs.magic.link/admin-sdk/ruby)!
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'magic-admin'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ bundle
|
26
|
+
```
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
$ gem install magic-admin
|
32
|
+
```
|
33
|
+
|
34
|
+
### Prerequisites
|
35
|
+
|
36
|
+
- Ruby 2.5+
|
37
|
+
|
38
|
+
## Quick Start
|
39
|
+
Before you start, you will need an API secret key. You can get one from the [Magic Dashboard](https://dashboard.magic.link/). Once you have the API secret key, you can instantiate a Magic object.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
require 'magic-admin'
|
43
|
+
|
44
|
+
magic = Magic.new(api_secret_key: '<YOUR_API_SECRET_KEY>')
|
45
|
+
|
46
|
+
magic.token.validate('DID_TOKEN')
|
47
|
+
|
48
|
+
# Read the docs to learn more! ๐
|
49
|
+
```
|
50
|
+
|
51
|
+
Optionally if you would like, you can load the API secret key from the environment variable, `MAGIC_API_SECRET_KEY`.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# Set the env variable `MAGIC_API_SECRET_KEY`.
|
55
|
+
|
56
|
+
magic = Magic.new
|
57
|
+
```
|
58
|
+
|
59
|
+
**Note**: The arguments passed to the `Magic` object takes precedence over the environment variables.
|
60
|
+
|
61
|
+
### Configure Network Strategy
|
62
|
+
The `Magic` object also takes in `retries`, `timeout` and `backoff` as optional arguments at the object instantiation time so you can override those values for your application setup.
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
magic = Magic.new(retries: 5, timeout: 10, backoff: 0.03)
|
66
|
+
|
67
|
+
```
|
68
|
+
|
69
|
+
## Changelog
|
70
|
+
See [Changelog](CHANGELOG.md)
|
71
|
+
|
72
|
+
## License
|
73
|
+
See [License](LICENSE.txt)
|