wetransfer 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/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +15 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CONTRIBUTING.md +152 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/wetransfer.rb +16 -0
- data/lib/wetransfer/client.rb +126 -0
- data/lib/wetransfer/connection.rb +77 -0
- data/lib/wetransfer/item.rb +14 -0
- data/lib/wetransfer/item_builder.rb +59 -0
- data/lib/wetransfer/transfer.rb +30 -0
- data/lib/wetransfer/transfer_builder.rb +28 -0
- data/lib/wetransfer/version.rb +3 -0
- data/spec/client_spec.rb +82 -0
- data/spec/connection_spec.rb +74 -0
- data/spec/item_builder_spec.rb +104 -0
- data/spec/spec_helper.rb +24 -0
- data/spec/test_server.rb +208 -0
- data/spec/wetransfer_spec.rb +7 -0
- data/wetransfer.gemspec +44 -0
- metadata +201 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a6bb6ae2971c42681f0f887d3bcd76f3e19041c5
|
4
|
+
data.tar.gz: 02e73980a479f35655e0a775072a0a2728d3f023
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a9badb333a33924c63de6ba39f0c40f05ce3444618164a166a08a21ff3d16e46b5f7c0bbb2d046f2674a8948146fdec26b6386716172fdd81cc71bdf9d9e916c
|
7
|
+
data.tar.gz: 8c6c6641be4a570ea300e75e24512896b0d55c4ea1efabb5f45c2277bd7378a19fc8196e6aab9d5079a42da8a7befbb5dfda8f7bc4dc56682c71746cc51b4db6
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.7
|
5
|
+
- 2.4.4
|
6
|
+
- 2.5.1
|
7
|
+
- jruby-9.0
|
8
|
+
before_install: gem install bundler -v 1.16.1
|
9
|
+
cache: bundler
|
10
|
+
matrix:
|
11
|
+
allow_failures:
|
12
|
+
- rvm: jruby-9.0
|
13
|
+
script:
|
14
|
+
- bundle exec rubocop -c .rubocop.yml --force-exclusion
|
15
|
+
- bundle exec rspec
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at developers@wetransfer.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,152 @@
|
|
1
|
+
# Contributing to wetransfer
|
2
|
+
|
3
|
+
Please take a moment to review this document in order to make the contribution
|
4
|
+
process easy and effective for everyone involved.
|
5
|
+
|
6
|
+
Following these guidelines helps to communicate that you respect the time of
|
7
|
+
the developers managing and developing this open source project. In return,
|
8
|
+
they should reciprocate that respect in addressing your issue or assessing
|
9
|
+
patches and features.
|
10
|
+
|
11
|
+
## What do I need to know to help?
|
12
|
+
|
13
|
+
If you are already familiar with the [Ruby Programming Language](https://www.ruby-lang.org/) you can start contributing code right away, otherwise look for issues labeled with *documentation* or *good first issue* to get started.
|
14
|
+
|
15
|
+
If you are interested in contributing code and would like to learn more about the technologies that we use, check out the (non-exhaustive) list below. You can also get in touch with us via an issue or email to noah@wetransfer.com and/or david@wetransfer.com to get additional information.
|
16
|
+
|
17
|
+
- [ruby](https://ruby-doc.org)
|
18
|
+
- [rspec](http://rspec.info/) (for testing)
|
19
|
+
|
20
|
+
# How do I make a contribution?
|
21
|
+
|
22
|
+
## Using the issue tracker
|
23
|
+
|
24
|
+
The issue tracker is the preferred mechanism for [bug reports](#bug-reports),
|
25
|
+
[feature requests](#feature-requests) and [submitting pull
|
26
|
+
requests](#pull-requests), but please respect the following restrictions:
|
27
|
+
|
28
|
+
* Please **do not** derail or troll issues. Keep the discussion on topic and respect the opinions of others. Adhere to the principles set out in the [Code of Conduct](https://github.com/WeTransfer/wetransfer/blob/master/CODE_OF_CONDUCT.md).
|
29
|
+
|
30
|
+
## Bug reports
|
31
|
+
|
32
|
+
A bug is a _demonstrable problem_ that is caused by code in the repository.
|
33
|
+
|
34
|
+
Bug reports are extremely helpful-thank you!
|
35
|
+
|
36
|
+
Guidelines for bug reports:
|
37
|
+
|
38
|
+
1. **Use the GitHub issue search** – check if the issue has already been
|
39
|
+
reported.
|
40
|
+
|
41
|
+
2. **Check if the issue has been fixed** – try to reproduce it using the
|
42
|
+
latest `master` branch in the repository.
|
43
|
+
|
44
|
+
3. **Isolate the problem** – create a [reduced test
|
45
|
+
case](http://css-tricks.com/reduced-test-cases/) and a live example.
|
46
|
+
|
47
|
+
A good bug report shouldn't leave others needing to chase you up for more
|
48
|
+
information. Please try to be as detailed as possible in your report. What is
|
49
|
+
your environment? What steps will reproduce the issue? What tool(s) or OS will
|
50
|
+
experience the problem? What would you expect to be the outcome? All these
|
51
|
+
details will help people to fix any potential bugs.
|
52
|
+
|
53
|
+
Example:
|
54
|
+
|
55
|
+
> Short and descriptive example bug report title
|
56
|
+
>
|
57
|
+
> A summary of the issue and the OS environment in which it occurs. If
|
58
|
+
> suitable, include the steps required to reproduce the bug.
|
59
|
+
>
|
60
|
+
> 1. This is the first step
|
61
|
+
> 2. This is the second step
|
62
|
+
> 3. Further steps, etc.
|
63
|
+
>
|
64
|
+
> `<url>` - a link to the reduced test case, if possible. Feel free to use a [Gist](https://gist.github.com).
|
65
|
+
>
|
66
|
+
> Any other information you want to share that is relevant to the issue being
|
67
|
+
> reported. This might include the lines of code that you have identified as
|
68
|
+
> causing the bug, and potential solutions (and your opinions on their
|
69
|
+
> merits).
|
70
|
+
|
71
|
+
## Feature requests
|
72
|
+
|
73
|
+
Feature requests are welcome. But take a moment to find out whether your idea
|
74
|
+
fits with the scope and aims of the project. It's up to *you* to make a strong
|
75
|
+
case to convince the project's developers of the merits of this feature. Please
|
76
|
+
provide as much detail and context as possible.
|
77
|
+
|
78
|
+
## So, you want to contribute a test that involves a sample file
|
79
|
+
|
80
|
+
That's awesome! Please do take care to add example files that fit within the gem's use case.
|
81
|
+
Make sure that the file you are adding is licensed for use within an MIT-licensed piece
|
82
|
+
of software. Ideally, this file is going to be something you have produced yourself
|
83
|
+
and you are permitted to share under the MIT license provisions.
|
84
|
+
|
85
|
+
## Pull requests
|
86
|
+
|
87
|
+
Good pull requests-patches, improvements, new features-are a fantastic
|
88
|
+
help. They should remain focused in scope and avoid containing unrelated
|
89
|
+
commits.
|
90
|
+
|
91
|
+
**Please ask first** before embarking on any significant pull request (e.g.
|
92
|
+
implementing features, refactoring code, porting to a different language),
|
93
|
+
otherwise you risk spending a lot of time working on something that the
|
94
|
+
project's developers might not want to merge into the project.
|
95
|
+
|
96
|
+
Please adhere to the coding conventions used throughout the project (indentation,
|
97
|
+
accurate comments, etc.) and any other requirements (such as test coverage).
|
98
|
+
|
99
|
+
The test suite can be run with `bundle exec rspec`.
|
100
|
+
|
101
|
+
Follow this process if you'd like your work considered for inclusion in the
|
102
|
+
project:
|
103
|
+
|
104
|
+
1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
|
105
|
+
and configure the remotes:
|
106
|
+
|
107
|
+
```bash
|
108
|
+
# Clone your fork of the repo into the current directory
|
109
|
+
git clone git@github.com:WeTransfer/wetransfer.git
|
110
|
+
# Navigate to the newly cloned directory
|
111
|
+
cd wetransfer
|
112
|
+
# Assign the original repo to a remote called "upstream"
|
113
|
+
git remote add upstream git@github.com:WeTransfer/wetransfer.git
|
114
|
+
```
|
115
|
+
|
116
|
+
2. If you cloned a while ago, get the latest changes from upstream:
|
117
|
+
|
118
|
+
```bash
|
119
|
+
git checkout <dev-branch>
|
120
|
+
git pull upstream <dev-branch>
|
121
|
+
```
|
122
|
+
|
123
|
+
3. Create a new topic branch (off the main project development branch) to
|
124
|
+
contain your feature, change, or fix:
|
125
|
+
|
126
|
+
```bash
|
127
|
+
git checkout -b <topic-branch-name>
|
128
|
+
```
|
129
|
+
|
130
|
+
4. Commit your changes in logical chunks and/or squash them for readability and
|
131
|
+
conciseness. Check out [this post](https://chris.beams.io/posts/git-commit/) or
|
132
|
+
[this other post](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) for some tips re: writing good commit messages.
|
133
|
+
|
134
|
+
5. Locally merge (or rebase) the upstream development branch into your topic branch:
|
135
|
+
|
136
|
+
```bash
|
137
|
+
git pull [--rebase] upstream <dev-branch>
|
138
|
+
```
|
139
|
+
|
140
|
+
6. Push your topic branch up to your fork:
|
141
|
+
|
142
|
+
```bash
|
143
|
+
git push origin <topic-branch-name>
|
144
|
+
```
|
145
|
+
|
146
|
+
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
|
147
|
+
with a clear title and description.
|
148
|
+
|
149
|
+
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
|
150
|
+
license your work under the same license as that used by the project, which you
|
151
|
+
can see by clicking [here](https://github.com/WeTransfer/wetransfer/blob/master/LICENSE.txt).
|
152
|
+
This provision also applies to the test files you include with the changed code as fixtures.
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 WeTransfer
|
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,102 @@
|
|
1
|
+
# WeTransfer's Ruby SDK
|
2
|
+
|
3
|
+
An open source Ruby SDK for the WeTransfer Open API
|
4
|
+
|
5
|
+
For your API key please visit our [developer portal](https://developers.wetransfer.com).
|
6
|
+
|
7
|
+
## Table of Contents
|
8
|
+
|
9
|
+
1. [Installation](#installation)
|
10
|
+
2. [Usage](#usage)
|
11
|
+
3. [Configuration](#configuration)
|
12
|
+
4. [Development](#development)
|
13
|
+
5. [Contributing](#contributing)
|
14
|
+
6. [License](#license)
|
15
|
+
7. [Code of Conduct](#code-of-conduct)
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
gem 'wetransfer'
|
23
|
+
```
|
24
|
+
|
25
|
+
And then execute:
|
26
|
+
|
27
|
+
$ bundle
|
28
|
+
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
$ gem install wetransfer
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
### Configuration
|
36
|
+
|
37
|
+
The gem allows you to configure several settings using environment variables.
|
38
|
+
|
39
|
+
- `WT_API_LOGGING_ON` can be set to (a string) "true" if you want to switch Faraday's default logging on.
|
40
|
+
|
41
|
+
- `WT_API_URL` can be set to a staging or test URL (something we do not offer yet, but plan to in the future)
|
42
|
+
|
43
|
+
- `WT_API_CONNECTION_PATH` can be set to prefix the paths passed to faraday - for example if you're testing against a test API or a different version.
|
44
|
+
|
45
|
+
### Super simple transfers
|
46
|
+
|
47
|
+
You'll need to retrieve an API key from [our developer portal](https://developers.wetransfer.com).
|
48
|
+
|
49
|
+
Be sure to not commit this key to github! If you do though, no worries, you can always revoke & create a new key from within the portal. You will most likely want to pass this to the client setter using an environment variable.
|
50
|
+
|
51
|
+
Now that you've got a wonderful WeTransfer API key, you can create a Client object like so:
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
# In a .env or other secret handling file, not checked in to version control:
|
55
|
+
WT_API_KEY=<your API key>
|
56
|
+
|
57
|
+
# In your project file:
|
58
|
+
@client = WeTransfer::Client.new(api_key: ENV['WT_API_KEY'])
|
59
|
+
```
|
60
|
+
|
61
|
+
Now that you've got the client set up you can use the `create_transfer` to, well, create a transfer!
|
62
|
+
|
63
|
+
If you pass item paths to the method it will handle the upload process itself, otherwise you can omit them and
|
64
|
+
use the `add_items` method once the transfer has been created.
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
transfer = @client.create_transfer(name: "My wonderful transfer", description: "I'm so excited to share this", items: ["/path/to/local/file_1.jpg", "/path/to/local/file_2.png", "/path/to/local/file_3.key"])
|
68
|
+
|
69
|
+
transfer.shortened_url = "https://we.tl/SSBsb3ZlIHJ1Ynk="
|
70
|
+
```
|
71
|
+
|
72
|
+
## Item upload flow
|
73
|
+
|
74
|
+
### `add_items`
|
75
|
+
|
76
|
+
If you want slightly more granular control over your transfer, create it without an `items` array, and then use `add_items` with the resulting transfer object.
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
transfer = @client.create_transfer(name: "My wonderful transfer", description: "I'm so excited to share this")
|
80
|
+
|
81
|
+
@client.add_items(transfer: @transfer, items: ["/path/to/local/file_1.jpg", "/path/to/local/file_2.png", "/path/to/local/file_3.key"])
|
82
|
+
|
83
|
+
transfer.shortened_url = "https://we.tl/d2V0cmFuc2Zlci5ob21lcnVuLmNv"
|
84
|
+
```
|
85
|
+
|
86
|
+
## Development
|
87
|
+
|
88
|
+
After forking and cloning down the repo, run `bin/setup` to install dependencies. Then, run `bundle exec rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
89
|
+
|
90
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
91
|
+
|
92
|
+
## Contributing
|
93
|
+
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/wetransfer/wetransfer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
99
|
+
|
100
|
+
## Code of Conduct
|
101
|
+
|
102
|
+
Everyone interacting in the WetransferRubySdk project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/wetransfer/wetransfer/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'wetransfer'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|