Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ifokeev/telegraph_api_ruby
A fully working telegra.ph/api ruby http client with DOM to node support and tests
https://github.com/ifokeev/telegraph_api_ruby
telegram telegraph telegraph-api
Last synced: 2 months ago
JSON representation
A fully working telegra.ph/api ruby http client with DOM to node support and tests
- Host: GitHub
- URL: https://github.com/ifokeev/telegraph_api_ruby
- Owner: ifokeev
- License: mit
- Created: 2018-09-09T20:11:39.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-09-09T21:10:10.000Z (over 6 years ago)
- Last Synced: 2024-11-27T17:40:06.244Z (3 months ago)
- Topics: telegram, telegraph, telegraph-api
- Language: Ruby
- Homepage:
- Size: 8.79 KB
- Stars: 9
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# telegraph_api_ruby
A Ruby interface to [Telegra.ph API](http://telegra.ph/api).
## Installation
Add following line to your Gemfile:
```ruby
gem 'telegraph_api_ruby'
```And then execute:
```shell
$ bundle
```Or install it system-wide:
```shell
$ gem install telegraph_api_ruby
```## Usage
```ruby
require 'telegraph_api_ruby'telegraph_access_token = 'YOUR_ACCESS_TOKEN'
html = %(
Hello World
)content = TelegraphApi::DomToNode.call(html)
data = {
access_token: telegraph_access_token,
title: 'Test page',
content: JSON.dump(content),
return_content: true
}result = TelegraphApi::Client.create_page(data)
result.url
```See [tests](https://github.com/ifokeev/telegraph_api_ruby/blob/master/test/test_telegraph_api.rb) also.
## Methods
See [Available methods](https://github.com/ifokeev/telegraph_api_ruby/blob/master/lib/telegraph_api_ruby/client.rb#L9-L19) and [Types](https://github.com/ifokeev/telegraph_api_ruby/tree/master/lib/telegraph_api_ruby/types).
You are able to call any method described on telegra.ph/api page right forward:
```
TelegraphApi::Client.getAccountInfo(access_token: 'TOKEN')```
Because this gem uses [method_missing](https://ruby-doc.org/core-2.1.0/BasicObject.html#method-i-method_missing) for unlisted in
[Available methods](https://github.com/ifokeev/telegraph_api_ruby/blob/master/lib/telegraph_api_ruby/client.rb#L9-L19) list.## Contributing
1. Fork it
2. Create your feature branch (git checkout -b feature/my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin feature/my-new-feature)
5. Create new Pull Request