little_light 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d4f25a0468bca3c68040660b4151aedddeca4b42
4
+ data.tar.gz: dfc1923f1a9bab96411fa3ed727ffa3c258c8c2c
5
+ SHA512:
6
+ metadata.gz: e176ca16ed21d0475539a454ec80e78e0b1c3ab22b0e31f1206cedee6925aca31b59b5b3ac1f763b93720a79f06e3ec79b56410b545b1c8b432655e97b89aa78
7
+ data.tar.gz: 46304b9e03e494d2322870f11f23a2da875855ad4462a0ae349b70594b26ad9881ff763588c56f1b60340df74949170a6780c7e0f858df8d3d087559ef2c52d4
@@ -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 brendanekane@gmail.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/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in little_light.gemspec
6
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Brendan
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.
@@ -0,0 +1,53 @@
1
+ # LittleLight
2
+
3
+ LittleLight is a simple wrapper written in Ruby to make API calls to the Destiny 2 database. The majority of methods only require you to supply an api-key, however some methods require Oauth2 authentication (which is not provided by this gem in any capacity).
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'little_light'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install little_light
20
+
21
+ ## Usage
22
+
23
+ A prerequisite to using this gem is having a valid api-key from Bungie. Without an api-key you will not be able to call any methods successfully.
24
+
25
+ To start off you need to instantiate the Client and supply it with an api-key as a parameter.
26
+ ```ruby
27
+ client = LittleLight::Client("api-key")
28
+ ```
29
+ Once you have instantiated the client you can call any methods in the lib folder on the client with the required parameters
30
+
31
+ ex/
32
+ ```ruby
33
+ client.search_bungie_net_by_username("robbinthehood") => returns an object with of all usernames containing the string "robbinthehood"
34
+ ```
35
+ You can find all the methods available to use in the lib folder, along with comments about what you should expect it to return, required params, as well as some links to destiny api docs for certain params.
36
+
37
+ ## Development
38
+
39
+ 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.
40
+
41
+ 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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/brendanekane/little_light. 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.
46
+
47
+ ## License
48
+
49
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
50
+
51
+ ## Code of Conduct
52
+
53
+ Everyone interacting in the LittleLight project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/little_light/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "little_light"
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__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require "little_light/version"
2
+ require 'little_light/client'
3
+ require 'little_light/user'
4
+ require 'little_light/clan'
5
+ require 'little_light/vendor'
6
+
7
+ module LittleLight
8
+ def self.new(options={})
9
+ LittleLight::Client.new(options)
10
+ end
11
+ end
@@ -0,0 +1,72 @@
1
+ module LittleLight
2
+ module Clan
3
+
4
+ #groupType 0 - general, 1 - clan
5
+
6
+ #both get_clan_by methods return exactly the same thing, just different ways of
7
+ #accessing information through params
8
+ def get_clan_by_name(groupName, groupType)
9
+ if groupName.match(" ")
10
+ groupName = groupName.split(" ").map {|el| el += "%20"}.join("")
11
+ end
12
+ data = self.class.get(
13
+ "/GroupV2/Name/#{groupName}/#{groupType}/",
14
+ headers: @headers
15
+ )
16
+ end
17
+
18
+ def get_clan_by_id(groupId)
19
+ data = self.class.get("/GroupV2/#{groupId}/",
20
+ headers: @headers)
21
+ end
22
+
23
+ # returns a list of available optional conserations for the clan
24
+ def get_clan_optional_convos(groupId)
25
+ data = self.class.get(
26
+ "/GroupV2/{groupId}/OptionalConversations/",
27
+ headers: @headers
28
+ )
29
+ end
30
+
31
+ # returns a list of active members in the clan
32
+ def get_clan_members(groupId)
33
+ data = self.class.get(
34
+ "/GroupV2/{groupId}/Members/",
35
+ headers: @headers
36
+ )
37
+ end
38
+
39
+ # returns a list of banned members
40
+ def get_banned_clan_members(groupId)
41
+ data = self.class.get(
42
+ "GroupV2/{groupId}/Banned/",
43
+ headers: @headers
44
+ )
45
+ end
46
+
47
+ # returns a hash of whether the rewards were unlocked or picked up along with their boolean state
48
+ def get_clan_weekly_state(groupId)
49
+ data = self.class.get(
50
+ "/Destiny2/Clan/#{groupId}/WeeklyRewardState/",
51
+ headers: @headers
52
+ )
53
+ end
54
+
55
+ # both of the next two clan member functions take an optional param for page number
56
+ # (which limits to 50 elements per page). Not sure how to implement that currently.
57
+ def get_clan_admin_founders(groupId)
58
+ data = self.class.get(
59
+ "/GroupV2/#{groupId}/AdminsAndFounder/",
60
+ headers: @headers
61
+ )
62
+ end
63
+
64
+
65
+ def get_clan_members(groupId)
66
+ data = self.class.get(
67
+ "/GroupV2/#{groupId}/Members/",
68
+ headers: @headers
69
+ )
70
+ end
71
+ end
72
+ end
@@ -0,0 +1,21 @@
1
+ require 'httparty'
2
+ require_relative 'user'
3
+ require_relative 'clan'
4
+ require_relative 'vendor'
5
+
6
+ module LittleLight
7
+ class Client
8
+ include HTTParty
9
+ format :json
10
+
11
+ base_uri 'www.bungie.net/Platform'
12
+
13
+ include User
14
+ include Clan
15
+ include Vendor
16
+
17
+ def initialize(api_key)
18
+ @headers = {"x-api-key" => api_key, "Content-Type" => "application/json" }
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,138 @@
1
+ module LittleLight
2
+ module User
3
+ def get_bungie_net_profile(bungieMembershipId)
4
+ data = self.class.get(
5
+ "/User/GetBungieNetUserById/#{bungieMembershipId}/",
6
+ headers: @headers
7
+ )
8
+ end
9
+
10
+
11
+ # returns a JSON object of potential users that match the given username
12
+ # gives basic overview of returned users, returns bungie.net membershipID but no Destiny membershipID
13
+ def search_bungie_net_by_username(username)
14
+ data = self.class.get(
15
+ "/User/SearchUsers?q=#{username}",
16
+ headers: @headers
17
+ )
18
+ end
19
+
20
+
21
+ # returns only the exact user on the given platform or nothing
22
+ # basically just gives the Destiny membershipID
23
+ # displayName is either GamerTag or PSN Name
24
+ def search_destiny_player(displayName, membershipType)
25
+ data = self.class.get(
26
+ "/Destiny2/SearchDestinyPlayer/#{membershipType}/#{displayName}/",
27
+ headers: @headers
28
+ )
29
+ end
30
+
31
+ # basically returns a combination of both search_bungie_net_by_username && search_destiny_player however
32
+ # the destinyMembershipId is needed to access this endpoint (which you can only really get from search_destiny_player)
33
+ def get_user_by_membership(destinyMembershipId, membershipType)
34
+ data = self.class.get(
35
+ "/User/GetMembershipsById/#{destinyMembershipId}/#{membershipType}/",
36
+ headers: @headers
37
+ )
38
+ end
39
+
40
+ # returns the same as the method above, doesn't require any parms to be passed in but does require a user to be
41
+ # signed in via Oauth2
42
+ def get_current_user_membership
43
+ data = self.class.get(
44
+ "/User/GetMembershipsForCurrentUser/",
45
+ headers: @headers
46
+ )
47
+ end
48
+
49
+
50
+ def get_user_themes
51
+ data = self.class.get(
52
+ "/User/GetAvailableThemes/",
53
+ headers: @headers
54
+ )
55
+ end
56
+
57
+
58
+ def get_user_partnerships(destinyMembershipId)
59
+ data = self.class.get(
60
+ "/User/#{destinyMembershipId}/Partnerships/",
61
+ headers: @headers
62
+ )
63
+ end
64
+
65
+
66
+ def get_linked_profiles(destinyMembershipId, membershipType)
67
+ data = self.class.get(
68
+ "/Destiny2/#{membershipType}/Profile/#{destinyMembershipId}"\
69
+ "/LinkedProfiles/",
70
+ headers: @headers
71
+ )
72
+ end
73
+
74
+
75
+ #groupType 0 - general, 1 - clan
76
+ #filter 0 - All, 1 - Founded, 2 - Not Founded
77
+ def get_groups_for_user(destinyMembershipId, membershipType, groupType, filter)
78
+ data = self.class.get(
79
+ "/GroupV2/User/#{membershipType}/#{destinyMembershipId}"\
80
+ "/#{filter}/#{groupType}/",
81
+ headers: @headers
82
+ )
83
+ end
84
+ # component query string 100 - profile, 200 - characters, 300 - items, 400 - vendors, 500 - kiosks
85
+ # https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType
86
+ # ^^^ Link to full list of components ^^^
87
+
88
+
89
+ # only 100 & 200 query strings will produce results here
90
+ def get_destiny_profile(destinyMembershipId, membershipType, component)
91
+ data = self.class.get(
92
+ "/Destiny2/#{membershipType}/Profile/#{destinyMembershipId}"\
93
+ "?components=#{component}",
94
+ headers: @headers
95
+ )
96
+ end
97
+
98
+
99
+ # only 200 query strings will produce results here
100
+ # for query strings that return a JSON object that has a key of
101
+ # privacy pointing to 2 - means that user need to be authenticated via
102
+ # OAuth 2.0 or user has privacy settings on.
103
+ # No real plans to implement OAuth in this gem.
104
+ def get_character(destinyMembershipId, membershipType, characterId, component)
105
+ data = self.class.get(
106
+ "/Destiny2/#{membershipType}/Profile/#{destinyMembershipId}"\
107
+ "/Character/#{characterId}?components=#{component}",
108
+ headers: @headers
109
+ )
110
+ end
111
+
112
+ # returns the stats of a specific item instance
113
+ def get_item(destinyMembershipId, membershipType, itemInstanceId)
114
+ data = self.class.get(
115
+ "/Destiny2/{membershipType}/Profile/{destinyMembershipId}/Item/"\
116
+ "{itemInstanceId}/",
117
+ headers: @headers
118
+ )
119
+ end
120
+
121
+ # the next two get_user methods return info relevant to the specific clans they're in
122
+ # but are user methods not clan methods
123
+ def get_user_clan_theme
124
+ data = self.class.get(
125
+ "/GroupV2/GetAvailableThemes/",
126
+ headers: @headers
127
+ )
128
+ end
129
+
130
+
131
+ def get_user_clan_avatar
132
+ data = self.class.get(
133
+ "/GroupV2/GetAvailableAvatars/",
134
+ headers: @headers
135
+ )
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,29 @@
1
+ module LittleLight
2
+ module Vendor
3
+
4
+ # this will return all possible vendors that have a rotating inventory.
5
+ # requires a components query string
6
+ # https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType
7
+
8
+ def get_all_vendors(destinyMembershipId, membershipType, characterId, component)
9
+ data = self.class.get(
10
+ "/Destiny2/#{membershipType}/Profile/#{destinyMembershipId}/"\
11
+ "Character/#{characterId}/Vendors?components=#{component}",
12
+ headers: @headers
13
+ )
14
+ end
15
+
16
+ # this will return the inventory of a single vendor that is supplied through the vendorHash param
17
+ # requires a components query string
18
+ # https://bungie-net.github.io/multi/schema_Destiny-DestinyComponentType.html#schema_Destiny-DestinyComponentType
19
+
20
+ def get_one_vendor(destinyMembershipId, membershipType, characterId, vendorHash)
21
+ data = self.class.get(
22
+ "/Destiny2/#{membershipType}/Profile/#{destinyMembershipId}/"\
23
+ "Character/#{characterId}/Vendors/#{vendorHash}?components=#{component}",
24
+ header: @headers
25
+ )
26
+ end
27
+
28
+ end
29
+ end
@@ -0,0 +1,3 @@
1
+ module LittleLight
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,28 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "little_light/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "little_light"
8
+ spec.version = LittleLight::VERSION
9
+ spec.authors = ["Brendan"]
10
+ spec.email = ["brendanekane@gmail.com"]
11
+
12
+ spec.summary = "Ruby wrapper for Destiny 2 API"
13
+ spec.homepage = "https://github.com/brendanekane/little_light"
14
+ spec.license = "MIT"
15
+
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: little_light
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Brendan
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ description:
56
+ email:
57
+ - brendanekane@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - CODE_OF_CONDUCT.md
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - bin/console
68
+ - bin/setup
69
+ - lib/little_light.rb
70
+ - lib/little_light/clan.rb
71
+ - lib/little_light/client.rb
72
+ - lib/little_light/user.rb
73
+ - lib/little_light/vendor.rb
74
+ - lib/little_light/version.rb
75
+ - little_light.gemspec
76
+ homepage: https://github.com/brendanekane/little_light
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.5.1
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Ruby wrapper for Destiny 2 API
100
+ test_files: []