bskyrb 0.2.1 → 0.3

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. metadata +4 -5
  3. data/lib/bskyrb.rb +0 -103
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa3ecd9b24a2ae044cfcc5ff1825f0f28f903089f62e6961b2c4404e1b24864c
4
- data.tar.gz: e171427efd25ba3cc22e8deb0c3e1819c6bc0b3131d985a367e4349c77b905bc
3
+ metadata.gz: 40ec46f163f09edf3dfb16ad8cacfb7f6e94ca44180e6c81726662e955448333
4
+ data.tar.gz: 593c0a5c08893dfaab8f0f940a20d60063bad04288fe843b8960845da9615f76
5
5
  SHA512:
6
- metadata.gz: 93d1ad04723d948e14e63fdbefcb902bb81448707018a1d8bf0344ec5aac46176bc1db5fc482f267456eaf0b7adf8daf116adff1e29496975ba106ce6974c15a
7
- data.tar.gz: d6eeb0e934ef49a29f58ea4eaba92d131b4c37f6277bc6becbe390f96f9797fd0617a2d163070ac117de38ec0eafdddeba8410ccd720f172aad16af8e79a2342
6
+ metadata.gz: 0ef42a458f55f1f83427c9799d033dbfeca6ed383b08d1e376edb9ef69d0fe492bf0310d291017fd5291720d372710b397b96887388a8d34f2a65cf1cbcfa2ce
7
+ data.tar.gz: a30eefe3afdd41403de6e0481dd455f5d2e9480b602064cd39a6e9426c292c6c207fb2e4f3ba90d7b7bf984f8c00c92a4d693cba569060a949fc8c466fd06720
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bskyrb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shreyan Jain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 1980-01-01 00:00:00.000000000 Z
11
+ date: 2023-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -72,8 +72,7 @@ email:
72
72
  executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
- files:
76
- - lib/bskyrb.rb
75
+ files: []
77
76
  homepage: https://github.com/ShreyanJain9/bskyrb
78
77
  licenses:
79
78
  - MIT
@@ -93,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
93
92
  - !ruby/object:Gem::Version
94
93
  version: '0'
95
94
  requirements: []
96
- rubygems_version: 3.3.20
95
+ rubygems_version: 3.4.10
97
96
  signing_key:
98
97
  specification_version: 4
99
98
  summary: Interact with bsky/atproto using Ruby
data/lib/bskyrb.rb DELETED
@@ -1,103 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # require_relative "bskyrb/version"
4
- require 'json'
5
- require 'net/http'
6
- require 'httparty'
7
- require 'date'
8
- module ATProto
9
- class Session
10
- def initialize(username, password, pds)
11
- @atp_host = pds
12
- @atp_auth_token = ""
13
- @did = ""
14
- @username = username
15
- # headers = { "Content-Type" => "application/json" }
16
- data = { "identifier" => username, "password" => password }.to_json
17
-
18
- uri = URI("#{@atp_host}/xrpc/com.atproto.server.createSession")
19
- response = Net::HTTP.post(uri, data, 'Content-Type' => 'application/json')
20
- # response = HTTParty.post(uri, body: data.to_json, headers: {'Content-Type' => 'application/json'} )
21
-
22
- parsed_response = JSON.parse(response.body)
23
-
24
- @atp_auth_token = parsed_response['accessJwt']
25
-
26
- if @atp_auth_token.nil?
27
- raise ValueError.new("No access token, is your password wrong?")
28
- end
29
-
30
- @did = parsed_response['did']
31
- end
32
- def getdid()
33
- return @did
34
- end
35
-
36
- def resolveHandle(username)
37
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => "application/json" }
38
- response = HTTParty.get("#{@atp_host}/xrpc/com.atproto.identity.resolveHandle?handle=#{username}", headers: headers)
39
-
40
- return response.body
41
- end
42
- def get_skoot_by_url(url)
43
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => "application/json" }
44
-
45
- username_of_person_in_link = url.split('/')[-3]
46
- did_of_person_in_link = JSON.parse(resolveHandle(username_of_person_in_link))['did']
47
- url_identifier = url.split('/')[-1]
48
-
49
- uri = "at://#{did_of_person_in_link}/app.bsky.feed.post/#{url_identifier}"
50
-
51
- response = HTTParty.get("#{@atp_host}/xrpc/app.bsky.feed.getPostThread?uri=#{uri}", headers: headers)
52
-
53
- return response
54
- end
55
-
56
- def uploadBlob(blob_path, content_type)
57
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => content_type }
58
- image_bytes = File.binread(blob_path)
59
-
60
- uri = URI("#{@atp_host}/xrpc/com.atproto.repo.uploadBlob")
61
- response = HTTParty.post("#{@atp_host}/xrpc/com.atproto.repo.uploadBlob", body: image_bytes, headers: headers)
62
-
63
- return response
64
- end
65
-
66
-
67
- def post(postcontent)
68
- timestamp = DateTime.now.iso8601(3)
69
- headers = { "Authorization" => "Bearer #{@atp_auth_token}", "Content-Type" => "application/json" }
70
-
71
- data = {
72
- "collection" => "app.bsky.feed.post",
73
- "$type" => "app.bsky.feed.post",
74
- "repo" => "#{@did}",
75
- "record" => {
76
- "$type" => "app.bsky.feed.post",
77
- "createdAt" => timestamp,
78
- "text" => postcontent
79
- }
80
- }
81
-
82
- uri = URI("#{@atp_host}/xrpc/com.atproto.repo.createRecord")
83
-
84
-
85
- resp = HTTParty.post(
86
- uri,
87
- body: data.to_json,
88
- headers: headers
89
- )
90
- # response = Net::HTTP.post(uri, data.to_json, headers)
91
- return resp
92
- end
93
-
94
- def method_missing(method_name, *args)
95
- message = "You called #{method_name} with #{args}. This method doesn't exist."
96
-
97
- raise NoMethodError, message
98
-
99
- end
100
- end
101
- end
102
-
103
-